Home > Web Front-end > HTML Tutorial > Why is there no Http header in Http response, but is directly html content? How to use C# to handle this situation_html/css_WEB-ITnose

Why is there no Http header in Http response, but is directly html content? How to use C# to handle this situation_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:45:51
Original
1538 people have browsed it

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+++++
Copy after login


-----------This is the response packet content:
<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>................
Copy after login


I use HttpWebRequest to send data (such as the request packet above) to the device, and the device responds (As the above response package), how to use C# to process it, I don’t want to use socket, or communication port such as TcpClient.


Reply to the discussion (solution)

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();
Copy after login

I don’t know if I understand what you mean.

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?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template