Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
4143491c
Commit
4143491c
authored
Aug 04, 2011
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add more MPEG-4 MIME types to sniffer, and disable MP4 sniffing.
R=rsc CC=golang-dev
https://golang.org/cl/4808056
parent
583f7243
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
sniff.go
src/pkg/http/sniff.go
+13
-2
sniff_test.go
src/pkg/http/sniff_test.go
+3
-1
No files found.
src/pkg/http/sniff.go
View file @
4143491c
...
...
@@ -98,7 +98,8 @@ var sniffSignatures = []sniffSig{
&
exactSig
{[]
byte
(
"
\x50\x4B\x03\x04
"
),
"application/zip"
},
&
exactSig
{[]
byte
(
"
\x1F\x8B\x08
"
),
"application/x-gzip"
},
mp4Sig
(
0
),
// TODO(dsymonds): Re-enable this when the spec is sorted w.r.t. MP4.
//mp4Sig(0),
textSig
(
0
),
// should be last
}
...
...
@@ -179,8 +180,18 @@ func (mp4Sig) match(data []byte, firstNonWS int) string {
// minor version number
continue
}
if
bytes
.
Equal
(
data
[
st
:
st
+
3
],
[]
byte
(
"mp4"
))
{
seg
:=
string
(
data
[
st
:
st
+
3
])
switch
seg
{
case
"mp4"
,
"iso"
,
"M4V"
,
"M4P"
,
"M4B"
:
return
"video/mp4"
/* The remainder are not in the spec.
case "M4A":
return "audio/mp4"
case "3gp":
return "video/3gpp"
case "jp2":
return "image/jp2" // JPEG 2000
*/
}
}
return
""
...
...
src/pkg/http/sniff_test.go
View file @
4143491c
...
...
@@ -35,7 +35,9 @@ var sniffTests = []struct {
{
"GIF 87a"
,
[]
byte
(
`GIF87a`
),
"image/gif"
},
{
"GIF 89a"
,
[]
byte
(
`GIF89a...`
),
"image/gif"
},
{
"MP4"
,
[]
byte
(
"
\x00\x00\x00\x18
ftypmp42
\x00\x00\x00\x00
mp42isom<
\x06
t
\xbf
mdat"
),
"video/mp4"
},
// TODO(dsymonds): Re-enable this when the spec is sorted w.r.t. MP4.
//{"MP4 video", []byte("\x00\x00\x00\x18ftypmp42\x00\x00\x00\x00mp42isom<\x06t\xbfmdat"), "video/mp4"},
//{"MP4 audio", []byte("\x00\x00\x00\x20ftypM4A \x00\x00\x00\x00M4A mp42isom\x00\x00\x00\x00"), "audio/mp4"},
}
func
TestDetectContentType
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment