Hello, if the server doesn't send the content-type header, how does the browser tell which kind of content he got? For example, when I get the SO logo with chrome, the image is intact, though the server doesn't state its extension (at least, explicitly)
views:
59answers:
3
+2
A:
Most browsers do content sniffing if the type is not explicitly declared in the HTTP header. They are looking for specific signatures they know and thereby guess the media type.
See the section Determining the type of a new resource in a browsing context in the HTML 5 specification or this Draft of Content-Type Processing Model for some examples.
Gumbo
2009-09-25 14:39:10
+2
A:
It can guess the content type by inspecting the file.
For example, PNG have "PNG" among the first 4 bytes.
Greg
2009-09-25 14:40:25
+1
A:
Different browsers handle it in different ways.
Internet Explorer guesses based on content. In fact has often ignored Content-Type
headers, instead using its own guess.
Some browsers also take the extension into account.
Stef
2009-09-25 14:40:33