MCPcopy Create free account
hub / github.com/cortexproject/cortex / tryBufferFromReader

Function tryBufferFromReader

pkg/util/http.go:263–270  ·  view source on GitHub ↗

tryBufferFromReader attempts to cast the reader to a `*bytes.Buffer` this is possible when using httpgrpc. If it fails it will return nil and false.

(reader io.Reader)

Source from the content-addressed store, hash-verified

261// tryBufferFromReader attempts to cast the reader to a `*bytes.Buffer` this is possible when using httpgrpc.
262// If it fails it will return nil and false.
263func tryBufferFromReader(reader io.Reader) (*bytes.Buffer, bool) {
264 if bufReader, ok := reader.(interface {
265 BytesBuffer() *bytes.Buffer
266 }); ok && bufReader != nil {
267 return bufReader.BytesBuffer(), true
268 }
269 return nil, false
270}
271
272// SerializeProtoResponse serializes a protobuf response into an HTTP response.
273func SerializeProtoResponse(w http.ResponseWriter, resp proto.Message, compression CompressionType) error {

Callers 1

decompressRequestFunction · 0.85

Calls 1

BytesBufferMethod · 0.80

Tested by

no test coverage detected