]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: add sniffing support for woff2
authorAgniva De Sarker <agnivade@yahoo.co.in>
Sat, 24 Mar 2018 18:45:53 +0000 (00:15 +0530)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 24 Mar 2018 19:33:34 +0000 (19:33 +0000)
Sniffing woff2 is now added to the spec -
https://github.com/whatwg/mimesniff/commit/e29b9f4a22843bf6c7f0177223b0147bc03e37f7

Change-Id: Ie63744454d0ee54ed0f985c2873d7eb20a14015a
Reviewed-on: https://go-review.googlesource.com/102455
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/sniff.go
src/net/http/sniff_test.go

index 365a36c79efafc2945e0cb337fe11a838274dfbc..b21bfab9ab2138c1376f3aeba4888243d8c9450f 100644 (file)
@@ -140,6 +140,7 @@ var sniffSignatures = []sniffSig{
        &exactSig{[]byte("OTTO"), "application/font-off"},
        &exactSig{[]byte("ttcf"), "application/font-cff"},
        &exactSig{[]byte("wOFF"), "application/font-woff"},
+       &exactSig{[]byte("wOF2"), "application/font-woff2"},
 
        &exactSig{[]byte("\x1A\x45\xDF\xA3"), "video/webm"},
        &exactSig{[]byte("\x52\x61\x72\x20\x1A\x07\x00"), "application/x-rar-compressed"},
index bf1f6be41b1a8d9f981f6c9702bb6189e7faa5db..1aaa54181ac5b6485c9b75db2eb2ce7ef66b8528 100644 (file)
@@ -64,8 +64,7 @@ var sniffTests = []struct {
        {"OTTO sample  I", []byte("\x4f\x54\x54\x4f\x00\x0e\x00\x80\x00\x03\x00\x60\x42\x41\x53\x45"), "application/font-off"},
 
        {"woff sample  I", []byte("\x77\x4f\x46\x46\x00\x01\x00\x00\x00\x00\x30\x54\x00\x0d\x00\x00"), "application/font-woff"},
-       // Woff2 is not yet recognized, change this test once mime-sniff working group adds woff2
-       {"woff2 not recognized", []byte("\x77\x4f\x46\x32\x00\x01\x00\x00\x00"), "application/octet-stream"},
+       {"woff2 sample", []byte("\x77\x4f\x46\x32\x00\x01\x00\x00\x00"), "application/font-woff2"},
 }
 
 func TestDetectContentType(t *testing.T) {