mirror of
https://github.com/golang/go
synced 2024-11-17 06:04:47 -07:00
net/http: sniff less
We were reading 1024 bytes but only using 512. Fixes #6311 R=golang-dev, iant CC=golang-dev https://golang.org/cl/13289047
This commit is contained in:
parent
c576bcbad5
commit
8272c14f7e
@ -146,10 +146,9 @@ func serveContent(w ResponseWriter, r *Request, name string, modtime time.Time,
|
||||
ctype = mime.TypeByExtension(filepath.Ext(name))
|
||||
if ctype == "" {
|
||||
// read a chunk to decide between utf-8 text and binary
|
||||
var buf [1024]byte
|
||||
var buf [sniffLen]byte
|
||||
n, _ := io.ReadFull(content, buf[:])
|
||||
b := buf[:n]
|
||||
ctype = DetectContentType(b)
|
||||
ctype = DetectContentType(buf[:n])
|
||||
_, err := content.Seek(0, os.SEEK_SET) // rewind to output whole file
|
||||
if err != nil {
|
||||
Error(w, "seeker can't seek", StatusInternalServerError)
|
||||
|
Loading…
Reference in New Issue
Block a user