The Server Committed a Protocol Violation. Section=Responsestatusline Error

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



Leave a reply



Submit