From: Agniva De Sarker Date: Sat, 24 Mar 2018 18:45:53 +0000 (+0530) Subject: net/http: add sniffing support for woff2 X-Git-Tag: go1.11beta1~1120 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bf8eef2adc167c2600ac53b8c1f0af5bcfa10ae3;p=gostls13.git net/http: add sniffing support for woff2 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 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/net/http/sniff.go b/src/net/http/sniff.go index 365a36c79e..b21bfab9ab 100644 --- a/src/net/http/sniff.go +++ b/src/net/http/sniff.go @@ -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"}, diff --git a/src/net/http/sniff_test.go b/src/net/http/sniff_test.go index bf1f6be41b..1aaa54181a 100644 --- a/src/net/http/sniff_test.go +++ b/src/net/http/sniff_test.go @@ -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) {