1
0
mirror of https://github.com/golang/go synced 2024-11-23 11:30:06 -07:00

net/http: Detect MIME type of v5 RAR archives

Change-Id: Id9dedc861523e2dafe0e67f70862973124fa07b3
GitHub-Last-Rev: b662561f19
GitHub-Pull-Request: golang/go#30909
Reviewed-on: https://go-review.googlesource.com/c/go/+/168039
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
bakape 2019-03-18 19:53:41 +00:00 committed by Brad Fitzpatrick
parent 689544c0b9
commit 27e444d5e6
2 changed files with 6 additions and 1 deletions

View File

@ -185,7 +185,8 @@ var sniffSignatures = []sniffSig{
// Archive types
&exactSig{[]byte("\x1F\x8B\x08"), "application/x-gzip"},
&exactSig{[]byte("PK\x03\x04"), "application/zip"},
&exactSig{[]byte("Rar \x1A\x07\x00"), "application/x-rar-compressed"},
&exactSig{[]byte("Rar \x1A\x07\x00"), "application/x-rar-compressed"}, // RAR v1.5-v4.0
&exactSig{[]byte("Rar \x1A\x07\x01\x00"), "application/x-rar-compressed"}, // RAR v5+
&exactSig{[]byte("\x00\x61\x73\x6D"), "application/wasm"},

View File

@ -72,6 +72,10 @@ 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"},
// Archive types
{"RAR v1.5-v4.0", []byte("Rar \x1A\x07\x00"), "application/x-rar-compressed"},
{"RAR v5+", []byte("Rar \x1A\x07\x01\x00"), "application/x-rar-compressed"},
}
func TestDetectContentType(t *testing.T) {