URLConnection.guessContentTypeFromStream() does not support UTF8 and UTF32 with BOM
Charles Lee
littlee at linux.vnet.ibm.com
Thu Mar 3 17:51:12 PST 2011
On 03/03/2011 12:48 AM, Alan Bateman wrote:
> Charles Lee wrote:
>> Hi guys,
>>
>> With test case[1] below, you can see guessContent does not support
>> UTF8/32 BOM.
> I don't see a problem with this proposal but I just wonder if this
> method is even used these days. It is a legacy method and I don't
> think anyone can rely on it to reliably detect any content type. I'm
> curious how you ran into this, was it a test or custom protocol
> handler that overrides getContentType and uses
> guessContentTypeFromStream as a fallback?
>
> -Alan.
Hi Alan,
Sorry for the late reply. This test case comes from a big test case,
which test more types of stream. I am not sure if no one use it. But
from the spec:
/Ideally, this routine would not be needed. But many |http| servers
return the incorrect content type; in addition, there are many
nonstandard extensions. Direct inspection of the bytes to determine the
content type is often more accurate than believing the content type
claimed by the |http| server.
/guessContentTypeFromStream is needed as a fallback.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/net-dev/attachments/20110304/c9ade239/attachment.html
More information about the net-dev
mailing list