惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
Jina AI
Jina AI
博客园_首页
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
Forbes - Security
Forbes - Security
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
N
News | PayPal Newsroom
S
Security Archives - TechRepublic
量子位
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
C
Cisco Blogs
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Scott Helme
Scott Helme
S
Securelist
Security Latest
Security Latest
爱范儿
爱范儿
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
美团技术团队
Know Your Adversary
Know Your Adversary
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
月光博客
月光博客
T
Tailwind CSS Blog
Cloudbric
Cloudbric
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
D
DataBreaches.Net
博客园 - 【当耐特】
有赞技术团队
有赞技术团队

博客园 - 快乐家++

QMT A股 量化程序开发资料 通过 PyWenCai 模块采集问财涨停数据的例子 均线粘合 【通达信】 MS-SQL事务处理语句 SQL Update:使用一个表的数据更新另一张表 CefSharp 使用备忘录 IIS7 伪静态 web.config 配置方法 针对不同.NET版本的条件编译 将Json数据 填充到 实例类 的函数 带查询参数 可分页 的 T-SQL 语句写法 当鼠标经过表格数据行时颜色不同且奇偶行颜色也不同 (纯CSS) JavaScript 版本的 RSA加密库文件 电工葵花宝典 一开关接线方法 c# 执行javascript 脚本 秒转换成时分秒 SQL2008中Merge的用法 C#将exe运行程序嵌入到自己的winform窗体中 如何让用户只能访问特定的数据库(MSSQL) 委托、回调 Lambda表达式书写方式
HttpWebRequest出错 服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF
快乐家++ · 2016-12-08 · via 博客园 - 快乐家++

服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF  

The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF 

主体意思是微软没有容忍不符合RFC 822中的httpHeader必须以CRLF结束的规定的服务器响应。 

一个解决方案是在application.config或web.config文件里加入 

  <system.net> 

    <settings> 

      <httpWebRequest useUnsafeHeaderParsing="true" /> 

    </settings> 

  </system.net> 

允许系统容忍(tolerant)只以CR或LF结尾的hearder信息 

using System.Reflection;

bool GetAllowUnsafeHeaderParsing() { //Get the assembly that contains the internal class Assembly aNetAssembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection)); if (aNetAssembly != null) { //Use the assembly in order to get the internal type for // the internal class Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal"); if (aSettingsType != null) { //Use the internal static property to get an instance // of the internal settings class. If the static instance // isn't created allready the property will create it for us. object anInstance = aSettingsType.InvokeMember("Section", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, null, null, new object[] { }); if (anInstance != null) { //Locate the private bool field that tells the // framework is unsafe header parsing should be // allowed or not FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField( "useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance); if (aUseUnsafeHeaderParsing != null) return (bool)aUseUnsafeHeaderParsing.GetValue(anInstance); } } } return false; } void SetAllowUnsafeHeaderParsing(bool val) { //Get the assembly that contains the internal class Assembly aNetAssembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection)); if (aNetAssembly != null) { //Use the assembly in order to get the internal type for // the internal class Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal"); if (aSettingsType != null) { //Use the internal static property to get an instance // of the internal settings class. If the static instance // isn't created allready the property will create it for us. object anInstance = aSettingsType.InvokeMember("Section", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, null, null, new object[] { }); if (anInstance != null) { //Locate the private bool field that tells the // framework is unsafe header parsing should be // allowed or not FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField( "useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance); if (aUseUnsafeHeaderParsing != null) { aUseUnsafeHeaderParsing.SetValue(anInstance, val); } } } } }