MCPcopy Index your code
hub / github.com/willnorris/imageproxy / peekContentType

Function peekContentType

imageproxy.go:350–356  ·  view source on GitHub ↗

peekContentType peeks at the first 512 bytes of p, and attempts to detect the content type. Returns empty string if error occurs.

(p *bufio.Reader)

Source from the content-addressed store, hash-verified

348// peekContentType peeks at the first 512 bytes of p, and attempts to detect
349// the content type. Returns empty string if error occurs.
350func peekContentType(p *bufio.Reader) string {
351 byt, err := p.Peek(512)
352 if err != nil && !errors.Is(err, bufio.ErrBufferFull) && !errors.Is(err, io.EOF) {
353 return ""
354 }
355 return http.DetectContentType(byt)
356}
357
358// copyHeader copies values for specified headers from src to dst, adding to
359// any existing values with the same header name.

Callers 2

TestPeekContentTypeFunction · 0.85
serveImageMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestPeekContentTypeFunction · 0.68