diff options
| author | Emmanuel Odeke <emm.odeke@gmail.com> | 2015-11-24 02:57:01 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-03-26 08:58:57 +0000 |
| commit | b9daf0a408acb4099eda268ed80203f83ecd3fa5 (patch) | |
| tree | 518479999c0db719530f610515eff4ccd2b8c4db /src/net/http/sniff_test.go | |
| parent | d53287d0c37de1e624648dc9a1b1be356a2acf13 (diff) | |
| download | go-b9daf0a408acb4099eda268ed80203f83ecd3fa5.tar.xz | |
net/http: add more audio/video mime sniffing
Following the spec at
https://mimesniff.spec.whatwg.org/#matching-an-audio-or-video-type-pattern
Adds signatures for:
+ audio/aiff
+ audio/basic
+ audio/midi
+ audio/mpeg
+ video/avi
Updates the signature for:
+ application/ogg
Also updates the pattern matching algorithm in
https://mimesniff.spec.whatwg.org/#matching-a-mime-type-pattern
by implementing clause 4 that dictates that the number of bytes in
the pattern must match the number of bytes in the mask.
Fixes #13383
Change-Id: Ie321f392e6570299c17176adf1c75f62f357e1e8
Reviewed-on: https://go-review.googlesource.com/17132
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/sniff_test.go')
| -rw-r--r-- | src/net/http/sniff_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/net/http/sniff_test.go b/src/net/http/sniff_test.go index e0085516da..ac404bfa72 100644 --- a/src/net/http/sniff_test.go +++ b/src/net/http/sniff_test.go @@ -39,7 +39,18 @@ var sniffTests = []struct { {"GIF 87a", []byte(`GIF87a`), "image/gif"}, {"GIF 89a", []byte(`GIF89a...`), "image/gif"}, + // Audio types. + {"MIDI audio", []byte("MThd\x00\x00\x00\x06\x00\x01"), "audio/midi"}, + {"MP3 audio/MPEG audio", []byte("ID3\x03\x00\x00\x00\x00\x0f"), "audio/mpeg"}, + {"WAV audio #1", []byte("RIFFb\xb8\x00\x00WAVEfmt \x12\x00\x00\x00\x06"), "audio/wave"}, + {"WAV audio #2", []byte("RIFF,\x00\x00\x00WAVEfmt \x12\x00\x00\x00\x06"), "audio/wave"}, + {"AIFF audio #1", []byte("FORM\x00\x00\x00\x00AIFFCOMM\x00\x00\x00\x12\x00\x01\x00\x00\x57\x55\x00\x10\x40\x0d\xf3\x34"), "audio/aiff"}, + {"OGG audio", []byte("OggS\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x7e\x46\x00\x00\x00\x00\x00\x00\x1f\xf6\xb4\xfc\x01\x1e\x01\x76\x6f\x72"), "application/ogg"}, + + // Video types. {"MP4 video", []byte("\x00\x00\x00\x18ftypmp42\x00\x00\x00\x00mp42isom<\x06t\xbfmdat"), "video/mp4"}, + {"AVI video #1", []byte("RIFF,O\n\x00AVI LISTÀ"), "video/avi"}, + {"AVI video #2", []byte("RIFF,\n\x00\x00AVI LISTÀ"), "video/avi"}, } func TestDetectContentType(t *testing.T) { |
