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



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: How to judge whether content type is truly "text/html"?
    ... MC> The response has one ContentType property. ... Should I try all kinds of Encoding? ... html lang are in English which is 33-127 in most of Encoding. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to judge whether content type is truly "text/html"?
    ... MC> The response has one ContentType property. ... Should I try all kinds of Encoding? ... html lang are in English which is 33-127 in most of Encoding. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: WSE 2.0 encoding error
    ... Microsoft MSDN Online Support Lead ... Subject: WSE 2.0 encoding error ... giberish from server service since it is output hebrew encoding response, ...
    (microsoft.public.dotnet.xml)
  • Re: WSE 2.0 and french text
    ... My Web Service is sending a response encoding with ISO-8859-1. ... If i change the settings of my HTTP Server in order to send a response ... >> These Web Services retrieve datas from an Oracle database. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Byte[] Problemchen (Socket.Response)
    ... Möglichkeiten Request zu senden bzw. eine Response zu konstruieren. ... Connection-Close oder Content-Legth (bzw. chuncked encoding), ... Prev by Date: ... Next by Date: ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)

Loading