Re: How to judge whether content type is truly "text/html"?



The property is not decided by the HTTP Response Header. It is decided by
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.

However, I have never heard of what you describe happening. If it did,
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).

--
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?



.



Relevant Pages

  • Re: HttpWebRequest
    ... The web site you refer me to comes up with a MS site that says "Location can not be found" ... we need to first get the Stream of the response and then read data from it. ... Make sure you use the correct encoding typeaccording to your scenario... ...
    (microsoft.public.dotnet.languages.vb)
  • How to judge whether content type is truly "text/html"?
    ... The response has one ContentType property. ... decided by http response header. ... Should I try all kinds of Encoding? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fun With AT&T
    ... I am trying to order new telephone service via your web site. ... If this response does not address your concern, ... Your AT&T Customer Service Representative ... Make sure to close all Internet Explorer windows ...
    (misc.consumers)
  • RE: HTTPS WebRequest and WebResponse
    ... > // Creates an HttpWebRequest for the specified URL. ... > // Displays all the headers present in the response received from the URI. ... > // Obtain a 'Stream' object associated with the response object. ... > StreamReader readStream = new StreamReader(ReceiveStream, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Read everything from socket
    ... There is no standard way to indicate a stream is finished ... line from the RETR command ... Or from the LIST command ... the actual byte length is given of the response steam. ...
    (perl.beginners)

Loading