Rumah > Artikel > hujung hadapan web > Http响应 为什么没有Http头,直接是html内容,怎么用C#处理这样的情况_html/css_WEB-ITnose
Http响应 为什么没有Http头,直接是html内容,怎么用C#处理这样的情况,
-----------这是请求包内容:
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,可以再具体点吗... HttpWebRequest.getresponse(),就会出错的.,可能是因为头的问题.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);request.Referer = "http://stackoverflow.com";request.UserAgent = "Mozilla/5.0";response = (HttpWebResponse)request.GetResponse();
响应没有http头的,直接是html数据了.我很苦恼,我是要与设备通信,设备是基于web的服务方式,
response = (HttpWebResponse)request.GetResponse(); 执行到这里时,http包送达设备,后设备有响应,响应过来的不是 http数据,页是 无http头的html文本数据,所以执行到这里,就会报错,这种情况怎么处理,还要得到响应的html文本数据 ?
ps:
response = (HttpWebResponse)request.GetResponse();
执行这步时系统抛出的异常:服务器提交了协议冲突. Section=ResponseStatusLine,这是类为没有http关的原因,怎么才能让他可以接受没有http头的数据而不报错,或是有比较好的办法来处理?
请问楼主是怎么用 HttpWebResponse 处理没有http头的响应的,为什么响应没有http头,远端服务器特地这么回复的吗?