Http response Why is there no Http header, it is directly html content? How to use C# to handle this situation?
-----------This is the content of the request package:
POST /DeviceSystemConfig HTTP/1.1Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*Referer: http://192.168.5.10/OptionsAccept-Language: zh-cnUser-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)Content-Type: application/x-www-form-urlencodedAccept-Encoding: gzip, deflateHost: 192.168.5.10Content-Length: 20Pragma: no-cacheB1=+Config+DACM+++++
<HTML><HEAD><TITLE>Config system</TITLE><META http-equiv=Content-Type content="text/html; charset=windows-1252"><META http-equiv=Content-Language content=en-us><SCRIPT language=JavaScript>................
response.setHeader()
xiaofan_sap, can you be more specific... HttpWebRequest.getresponse(), it will go wrong. It may be because of the header problem.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);request.Referer = "http://stackoverflow.com";request.UserAgent = "Mozilla/5.0";response = (HttpWebResponse)request.GetResponse();
The response does not have an http header, it is directly html data. I am very distressed. I want to communicate with the device, which is based on the web. Service mode,
response = (HttpWebResponse)request.GetResponse(); When executed here, the http packet is delivered to the device, and then the device responds. The response is not http data, but the page is html text data without http header. So when the execution reaches this point, an error will be reported. How to deal with this situation and get the response html text data?
ps:
response = (HttpWebResponse)request.GetResponse();
The exception thrown by the system when executing this step: The server submitted a protocol conflict. Section=ResponseStatusLine. This is the reason why the class does not have http connection. How can we allow it to accept data without http header without reporting an error, or if there is What's a better way to deal with it?
May I ask how the author uses HttpWebResponse to handle responses without http headers? Why does the response have no http headers? Did the remote server reply like this specifically?