MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / streamData

Method streamData

handlers/stream/handler.go:178–194  ·  view source on GitHub ↗

streamData copies the image data from the response body to the response writer

(res *http.Response)

Source from the content-addressed store, hash-verified

176
177// streamData copies the image data from the response body to the response writer
178func (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
196func (s *request) wrapError(err error) *server.Error {
197 return server.NewError(errctx.WrapWithStackSkip(err, 1), errCategoryStreaming)

Callers 1

executeMethod · 0.95

Calls 3

LogResponseFunction · 0.92
GetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected