Re: How to judge whether content type is truly "text/html"?
- From: "Morgan Cheng" <morgan.chengmo@xxxxxxxxx>
- Date: 21 Sep 2006 08:54:46 -0700
Kevin Spencer 写道:
The property is not decided by the HTTP Response Header. It is decided byYes, web server can config the response MIME type, which turns to be in
the web server and/or the developer who created the web site. The problem
here is, the reason for the ContentType header is to tell the client what is
stored in the stream of bits it is sending. Since a stream of bits is just
1's and 0's there's no way to tell without it.
HTTP response header. That is my understanding.
However, I have never heard of what you describe happening. If it did,I tried to manually set one html to be "image/jpeg" type in IIS6. Then
browsers would not be able to view the content, and whomever created the web
site would know about it very shortly (from the response of the users).
access the page from another machine and ambush the http package with
Fiddle. It shows that the response header has "ContentType:
image/jpeg". Interestingly, IE still show the html page, while Firefox
cannot show it up. It looks that IE does further job.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
A watched clock never boils.
"Morgan Cheng" <morgan.chengmo@xxxxxxxxx> wrote in message
news:1158847522.975327.265330@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I know that HttpWebRequest.GetResponse() generates a HttpWebResonse.
The response has one ContentType property. But the property is just
decided by http response header. It is possible that the content is
actually HTML, while the ContentType is "image/jpeg".
Is there any effective way to judge whether the response type is truly
"text"?
I have a idea to read the first several bytes of the response stream;
and check whether they are real displayable characters. But, they can
be any kind of Encoding. Should I try all kinds of Encoding?
.
- Follow-Ups:
- Re: How to judge whether content type is truly "text/html"?
- From: Kevin Spencer
- Re: How to judge whether content type is truly "text/html"?
- References:
- How to judge whether content type is truly "text/html"?
- From: Morgan Cheng
- Re: How to judge whether content type is truly "text/html"?
- From: Kevin Spencer
- How to judge whether content type is truly "text/html"?
- Prev by Date: NAnt delete task fails on network share
- Next by Date: Re: OSQL userName and Password Prompt.
- Previous by thread: Re: How to judge whether content type is truly "text/html"?
- Next by thread: Re: How to judge whether content type is truly "text/html"?
- Index(es):
Relevant Pages
|