(req *http.Request)
| 98 | } |
| 99 | |
| 100 | func (b *ProxyBackend) doBackendRequest(req *http.Request) (int, []byte, error) { |
| 101 | // Honor the read timeout. |
| 102 | ctx, cancel := context.WithTimeout(context.Background(), b.timeout) |
| 103 | defer cancel() |
| 104 | |
| 105 | // Execute the request. |
| 106 | res, err := b.client.Do(req.WithContext(ctx)) |
| 107 | if err != nil { |
| 108 | return 0, nil, errors.Wrap(err, "executing backend request") |
| 109 | } |
| 110 | |
| 111 | // Read the entire response body. |
| 112 | defer res.Body.Close() |
| 113 | body, err := io.ReadAll(res.Body) |
| 114 | if err != nil { |
| 115 | return 0, nil, errors.Wrap(err, "reading backend response") |
| 116 | } |
| 117 | |
| 118 | return res.StatusCode, body, nil |
| 119 | } |
no test coverage detected