MCPcopy Create free account
hub / github.com/CPChain/chain / DialHTTPWithClient

Function DialHTTPWithClient

api/rpc/http.go:71–83  ·  view source on GitHub ↗

DialHTTPWithClient creates a new RPC client that connects to an RPC server over HTTP using the provided HTTP Client.

(endpoint string, client *http.Client)

Source from the content-addressed store, hash-verified

69// DialHTTPWithClient creates a new RPC client that connects to an RPC server over HTTP
70// using the provided HTTP Client.
71func DialHTTPWithClient(endpoint string, client *http.Client) (*Client, error) {
72 req, err := http.NewRequest(http.MethodPost, endpoint, nil)
73 if err != nil {
74 return nil, err
75 }
76 req.Header.Set("Content-Type", contentType)
77 req.Header.Set("Accept", contentType)
78
79 initctx := context.Background()
80 return newClient(initctx, func(context.Context) (net.Conn, error) {
81 return &httpConn{client: client, req: req, closed: make(chan struct{})}, nil
82 })
83}
84
85// DialHTTP creates a new RPC client that connects to an RPC server over HTTP.
86func DialHTTP(endpoint string) (*Client, error) {

Callers 1

DialHTTPFunction · 0.85

Calls 2

newClientFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected