@@ -62,9 +62,10 @@ func (hc *httpConn) Close() error {
6262 return nil
6363}
6464
65- // DialHTTP creates a new RPC clients that connection to an RPC server over HTTP.
66- func DialHTTP (endpoint string ) (* Client , error ) {
67- req , err := http .NewRequest ("POST" , endpoint , nil )
65+ // DialHTTPWithClient creates a new RPC clients that connection to an RPC server over HTTP
66+ // using the provided HTTP Client.
67+ func DialHTTPWithClient (endpoint string , client * http.Client ) (* Client , error ) {
68+ req , err := http .NewRequest (http .MethodPost , endpoint , nil )
6869 if err != nil {
6970 return nil , err
7071 }
@@ -73,10 +74,15 @@ func DialHTTP(endpoint string) (*Client, error) {
7374
7475 initctx := context .Background ()
7576 return newClient (initctx , func (context.Context ) (net.Conn , error ) {
76- return & httpConn {client : new (http. Client ) , req : req , closed : make (chan struct {})}, nil
77+ return & httpConn {client : client , req : req , closed : make (chan struct {})}, nil
7778 })
7879}
7980
81+ // DialHTTP creates a new RPC clients that connection to an RPC server over HTTP.
82+ func DialHTTP (endpoint string ) (* Client , error ) {
83+ return DialHTTPWithClient (endpoint , new (http.Client ))
84+ }
85+
8086func (c * Client ) sendHTTP (ctx context.Context , op * requestOp , msg interface {}) error {
8187 hc := c .writeConn .(* httpConn )
8288 respBody , err := hc .doRequest (ctx , msg )
0 commit comments