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

Method sendHTTP

api/rpc/http.go:90–112  ·  view source on GitHub ↗
(ctx context.Context, op *requestOp, msg interface{})

Source from the content-addressed store, hash-verified

88}
89
90func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}) error {
91 hc := c.writeConn.(*httpConn)
92 respBody, err := hc.doRequest(ctx, msg)
93 if respBody != nil {
94 defer respBody.Close()
95 }
96
97 if err != nil {
98 if respBody != nil {
99 buf := new(bytes.Buffer)
100 if _, err2 := buf.ReadFrom(respBody); err2 == nil {
101 return fmt.Errorf("%v %v", err, buf.String())
102 }
103 }
104 return err
105 }
106 var respmsg jsonrpcMessage
107 if err := json.NewDecoder(respBody).Decode(&respmsg); err != nil {
108 return err
109 }
110 op.resp <- &respmsg
111 return nil
112}
113
114func (c *Client) sendBatchHTTP(ctx context.Context, op *requestOp, msgs []*jsonrpcMessage) error {
115 hc := c.writeConn.(*httpConn)

Callers 1

CallContextMethod · 0.95

Calls 3

doRequestMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected