(ctx context.Context, msg interface{})
| 129 | } |
| 130 | |
| 131 | func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadCloser, error) { |
| 132 | body, err := json.Marshal(msg) |
| 133 | if err != nil { |
| 134 | return nil, err |
| 135 | } |
| 136 | req := hc.req.WithContext(ctx) |
| 137 | req.Body = ioutil.NopCloser(bytes.NewReader(body)) |
| 138 | req.ContentLength = int64(len(body)) |
| 139 | |
| 140 | resp, err := hc.client.Do(req) |
| 141 | if err != nil { |
| 142 | return nil, err |
| 143 | } |
| 144 | if resp.StatusCode < 200 || resp.StatusCode >= 300 { |
| 145 | return resp.Body, errors.New(resp.Status) |
| 146 | } |
| 147 | return resp.Body, nil |
| 148 | } |
| 149 | |
| 150 | // httpReadWriteNopCloser wraps a io.Reader and io.Writer with a NOP Close method. |
| 151 | type httpReadWriteNopCloser struct { |
no outgoing calls
no test coverage detected