streamData copies the image data from the response body to the response writer
(res *http.Response)
| 176 | |
| 177 | // streamData copies the image data from the response body to the response writer |
| 178 | func (s *request) streamData(res *http.Response) { |
| 179 | buf := streamBufPool.Get().(*[]byte) //nolint:forcetypeassert |
| 180 | defer streamBufPool.Put(buf) |
| 181 | |
| 182 | _, copyerr := io.CopyBuffer(s.rw, res.Body, *buf) |
| 183 | |
| 184 | server.LogResponse( |
| 185 | s.reqID, s.imageRequest, res.StatusCode, nil, |
| 186 | slog.String("image_url", s.imageURL), |
| 187 | slog.Any("processing_options", s.opts), |
| 188 | ) |
| 189 | |
| 190 | // We've got to skip logging here |
| 191 | if copyerr != nil { |
| 192 | panic(http.ErrAbortHandler) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | func (s *request) wrapError(err error) *server.Error { |
| 197 | return server.NewError(errctx.WrapWithStackSkip(err, 1), errCategoryStreaming) |
no test coverage detected