System.Net.WebException: The server committed a protocol violation
Set
request.KeepAlive = false;
http://www.webmonkeys.org.uk/2012/09/c-the-server-committed-a-protocol-violation-sectionresponsestatusline/#comment-60
Also, the useUnsafeHeaderParsing config value that you pasted has it set as false, when you should be setting it to true, if you're attempting to get past this issue.
The server committed a protocol violation. Section=ResponseStatusLine
Well, I tried every suggestion I could find here on StackOverflow and elsewhere on the web, but never got an implementation of HttpWebRequest to work for me, so I tried using TcpClient instead after reading this:
How To Set useUnsafeHeaderParsing For .NET Compact Framework
To get it to work for me, I had to modify this line:
sw.WriteLine(string.Format("GET /{0} HTTP/1.1", pathAndQueryString));
to:
sw.WriteLine(string.Format("GET /{0} {1}", pathAndQueryString, Environment.NewLine+Environment.NewLine));
And that worked.
C#: HttpClient, The server committed a protocol violation. Section=ResponseStatusLine
The underlying problem is that the PATCH response includes content within the body of the response. Ensure that the server does not send content when sending a 204 No Content.
Related Topics
How to Assign a Func<> Conditionally Between Lambdas Using the Conditional Ternary Operator
Timeouts with Long Running ASP.NET MVC Core Controller Httppost Method
Why Cannot C# Generics Derive from One of the Generic Type Parameters Like They Can in C++ Templates
Not Ableto Serialize Dictionary with Complex Key Using JSON.Net
Wpf: How to Dynamically Add Controls in Dynamically Created Wpf Window
How to Get the Pid of the Parent Process of My Application
How to Make Multi-Language App in Winforms
Nullable Type Is Not a Nullable Type
Using the Iterator Variable of Foreach Loop in a Lambda Expression - Why Fails
How Does JSON Deserialization in C# Work
C#: How to Make It Harder for Hacker/Cracker to Get Around or Bypass the Licensing Check
How to Check If a String Exists in Another String
Format Timespan Greater Than 24 Hour
There Is No Argument Given That Corresponds to the Required Formal Parameter - .Net Error
How to Use Non-Thread-Safe Async/Await APIs and Patterns with ASP.NET Web API