解决The server committed a protocol violation. Section=ResponseStatusLine 的方法
2016-07-18 13:28
453 查看
编写了一个程序,用于抓取网页上的一些信息,原来运行的很正常,某一天发生了错误
HttpWebResponse.GetResponse() 抛出以下异常:
The server committed a protocol violation. Section=ResponseStatusLine
在网上查了好久,发现很多人遇到了这个问题
这个是因为微软没有容忍不符合RFC 822中的httpHeader必须以CRLF结束的规定的服务器响应。
Apparently the problem is that starting with .NET 1.1 SP2 the HTTP protocol usage has been made more strict and any issApparently the problem is that starting with .NET 1.1 SP2 the HTTP protocol usage has been made more strict and any issue ue in the HTTP headers
- such as returning only a CR intead of CRLF pair at the end of a header - apparently throws the header for a loop.
通过修改配置文件解决:
For windows form applcation, create a new configuration file [application name].exe.config in the same directory of execution file. For web application, please modify web.config like below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing= "true " />
</settings>
</system.net>
</configuration>
HttpWebResponse.GetResponse() 抛出以下异常:
The server committed a protocol violation. Section=ResponseStatusLine
在网上查了好久,发现很多人遇到了这个问题
这个是因为微软没有容忍不符合RFC 822中的httpHeader必须以CRLF结束的规定的服务器响应。
Apparently the problem is that starting with .NET 1.1 SP2 the HTTP protocol usage has been made more strict and any issApparently the problem is that starting with .NET 1.1 SP2 the HTTP protocol usage has been made more strict and any issue ue in the HTTP headers
- such as returning only a CR intead of CRLF pair at the end of a header - apparently throws the header for a loop.
通过修改配置文件解决:
For windows form applcation, create a new configuration file [application name].exe.config in the same directory of execution file. For web application, please modify web.config like below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing= "true " />
</settings>
</system.net>
</configuration>
相关文章推荐
- std::string用法总结
- html 基本标签 ---字体
- 北大百练+最长最短单词+gets的使用
- python的排序函数
- 二分图匹配(缩点建图)—— Fire Net ( HDU 1045 )
- MySQL 和Oracle里的关键词
- XSI IPC为什么需要键来标识内核IPC结构
- java多线程—Runnable、Thread、Callable
- MySQL Quick guide
- 无法访问localhost和127.0.0.1的内容
- 如何使360浏览器中的Google可用
- toggle()用法
- 文件打开模式 w+ r+ a+ 区别和辨析
- JAVA 新闻
- [Java]Java程序的编译步骤
- S5pv210裸机实验——SDRAM重定位
- android.content.res.Resources$NotFoundException: String resource ID #0xffffffff
- mysql数据库语句
- TVP5150视频解码芯片 调试总结
- Meta viewport (视口元信息标签)