服务器提交协议冲突 Section=ResponseStatusLine 的解决办法
来源:互联网 发布:淘宝客软件哪个好 编辑:程序博客网 时间:2024/05/01 03:35
最近在用.net写一个网络蜘蛛,发现对有的网站用HttpWebrequest抓取网页的时候会报错,捕获异常提示:"服务器提交了协议冲突 Section=ResponseStatusLine ”,改用WebClient也是同样问题,后来知道,WebClient是对HttpWebrequest进一步进行了封装。
最后终于找到问题根源:The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF 微软没有容忍不符合RFC 822中的httpHeader必须以CRLF结束的规定的服务器响应。
通过修改配置文件解决:在app.config(WinForm)或web.config(Web)文件里修改。
WinForm下的app.config文件中添加:
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
完整 app.config文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>
编译以后会在Debug下面自动创建一个 程序名.exe.config 的配置文件
希望大家能少走弯路,Good Luck~
- 服务器提交协议冲突 Section=ResponseStatusLine 的解决办法
- 服务器提交协议冲突 Section=ResponseStatusLine 的解决办法
- 服务器提交协议冲突 Section=ResponseStatusLine 的解决办法
- 服务器提交了协议冲突. Section=ResponseStatusLine
- C# Winform/Server 提交协议冲突 Section=ResponseStatusLine 的解决,可能是服务器引起的异常
- 关于“服务器提交了协议冲突. Section=ResponseStatusLine"问题请
- 服务器提交了协议冲突. Section=ResponseStatusLine,WebClient使用Cookie
- Section=ResponseStatusLine的解决
- 服务器提交了协议冲突.Section=ResponseHeader Detail=CR 后面必须是LF
- 服务器提交了协议冲突.Section=ResponseHeader Detail=CR后面必须是LF
- 服务器提交了协议冲突.Section=ResponseHeader Detail=CR 后面必须是LF .
- C# 服务器提交了协议冲突Section=ResponseHeader Detail=CR 后面必须 LF
- ASP.NET 中抓取网页内容 并出现服务器提交了协议冲突. Section=ResponseHeader 解决方案
- .net中FTP GetResponse“基础连接已关闭:服务器提交了协议冲突”的解决办法
- 解决The server committed a protocol violation. Section=ResponseStatusLine 的方法
- FTP基础连接已关闭:服务器提交了协议冲突(C#)解决办法
- 服务器提交了协议冲突,解决方法
- 服务器提交了协议冲突. 终极解决方案
- java之路(五) 转载
- Intent在Android中的几种用法
- JavaScript防止复制,屏蔽鼠标右键等常用实用技巧
- 为 TPanel 增加 OnPaint 事件
- java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatch
- 服务器提交协议冲突 Section=ResponseStatusLine 的解决办法
- SQL如何合并查询结果
- Flex tips
- 解决MySQL从库延迟问题的几种方法
- python安装第三方库一般方式和easy_install方式
- 银行卡的交易与结算流程(转)
- SetWindowPos
- 使用MySQL Proxy解决MySQL主从同步延迟
- QString char*