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+++++
-----------这是响应包内容:
config system................
我用httpwebrequest去发送数据(如上请求包)到设备,设备响应(如上响应包),怎么用c#处理,我不想用socket,或tcpclient的之类的通讯端口.
回复讨论(解决方案) 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头,远端服务器特地这么回复的吗?