aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/sniff_test.go
diff options
context:
space:
mode:
authorKshitij Saraogi <kshitijsaraogi@gmail.com>2019-03-04 16:29:25 +0530
committerEmmanuel Odeke <emm.odeke@gmail.com>2019-03-06 07:31:18 +0000
commit583fddf3bc85802869ce2d286fe8b32cc6728bc8 (patch)
treeb7a15154eeadf6498f4fbcecdf6d9b972176e265 /src/net/http/sniff_test.go
parent43e8fd4ef1ae24f1505bd34708fc30aa2b736c52 (diff)
downloadgo-583fddf3bc85802869ce2d286fe8b32cc6728bc8.tar.xz
net/http: remove discrepancies between the MIME Sniffing Spec and its implementation
The change fixes the following deviations between the existing implementation and the Spec: 1. Using pattern instead of "mask" for assertion and iteration in the Pattern Matching Algorithm. 2. Rename "image/vnd.microsoft.icon" to "image/x-icon" and add another signature for the same. 3. Using named strings instead of hexadecimal representation in "application/zip" and "application/x-rar-compressed". 4. Reordering "sniffSignatures" in accordance with the Spec section "Identifying a resource with an unknown MIME type". In addition to the above fixes, unit tests for Image MIME type group are added. Fixes #30570 Change-Id: I97d2ae22b426c3c57bf8efd2ed9396c0be983688 Reviewed-on: https://go-review.googlesource.com/c/go/+/165277 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/sniff_test.go')
-rw-r--r--src/net/http/sniff_test.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/net/http/sniff_test.go b/src/net/http/sniff_test.go
index b4d3c9f0cc..b752f23382 100644
--- a/src/net/http/sniff_test.go
+++ b/src/net/http/sniff_test.go
@@ -36,8 +36,14 @@ var sniffTests = []struct {
{"XML", []byte("\n<?xml!"), "text/xml; charset=utf-8"},
// Image types.
+ {"Windows icon", []byte("\x00\x00\x01\x00"), "image/x-icon"},
+ {"Windows cursor", []byte("\x00\x00\x02\x00"), "image/x-icon"},
+ {"BMP image", []byte("BM..."), "image/bmp"},
{"GIF 87a", []byte(`GIF87a`), "image/gif"},
{"GIF 89a", []byte(`GIF89a...`), "image/gif"},
+ {"WEBP image", []byte("RIFF\x00\x00\x00\x00WEBPVP"), "image/webp"},
+ {"PNG image", []byte("\x89PNG\x0D\x0A\x1A\x0A"), "image/png"},
+ {"JPEG image", []byte("\xFF\xD8\xFF"), "image/jpeg"},
// Audio types.
{"MIDI audio", []byte("MThd\x00\x00\x00\x06\x00\x01"), "audio/midi"},