summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAgniva De Sarker <agnivade@yahoo.co.in>2018-05-16 19:29:41 +0530
committerBrad Fitzpatrick <bradfitz@golang.org>2018-06-10 17:04:22 +0000
commitb3562658fddef6e9008379cac16c04c26784b7ed (patch)
tree737578ffc2f281c4271662285852b4846b057809
parenta5f83037aeb74032870946c20780e6ba61f326a2 (diff)
downloadgo-git-b3562658fddef6e9008379cac16c04c26784b7ed.tar.gz
net/http: add application/wasm mime type
Although not part of http://mimesniff.spec.whatwg.org, for WASM streaming compilation to happen, the response needs to have the application/wasm MIME type as mentioned here: https://webassembly.github.io/spec/web-api/index.html#streaming-modules. And all current browsers prevent streaming compilation from happening if this MIME type is not present in the response. The magic number is mentioned here: https://webassembly.org/docs/binary-encoding Since we are already adding WASM support, it makes sense to support this MIME type. Change-Id: I8dd7b413a8c438a5c23c29d843b42f6da2a20ba4 Reviewed-on: https://go-review.googlesource.com/113396 Reviewed-by: Richard Musiol <neelance@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/net/http/sniff.go2
-rw-r--r--src/net/http/sniff_test.go1
2 files changed, 3 insertions, 0 deletions
diff --git a/src/net/http/sniff.go b/src/net/http/sniff.go
index ff934ff357..c1494abb4c 100644
--- a/src/net/http/sniff.go
+++ b/src/net/http/sniff.go
@@ -147,6 +147,8 @@ var sniffSignatures = []sniffSig{
&exactSig{[]byte("\x50\x4B\x03\x04"), "application/zip"},
&exactSig{[]byte("\x1F\x8B\x08"), "application/x-gzip"},
+ &exactSig{[]byte("\x00\x61\x73\x6D"), "application/wasm"},
+
mp4Sig{},
textSig{}, // should be last
diff --git a/src/net/http/sniff_test.go b/src/net/http/sniff_test.go
index b9e9488610..b4d3c9f0cc 100644
--- a/src/net/http/sniff_test.go
+++ b/src/net/http/sniff_test.go
@@ -65,6 +65,7 @@ var sniffTests = []struct {
{"woff sample I", []byte("\x77\x4f\x46\x46\x00\x01\x00\x00\x00\x00\x30\x54\x00\x0d\x00\x00"), "font/woff"},
{"woff2 sample", []byte("\x77\x4f\x46\x32\x00\x01\x00\x00\x00"), "font/woff2"},
+ {"wasm sample", []byte("\x00\x61\x73\x6d\x01\x00"), "application/wasm"},
}
func TestDetectContentType(t *testing.T) {