HttpClient, the server committed a protocol violation Section = ResponseHeader Detail = CR must follow LF

I am using HttpClient to communicate with my GoPro camera over Wi-Fi, but I am getting the following error. " The server has detected a protocol violation. The = ResponseHeader Detail = CR section must be followed by an LF " Although I have notified them, I cannot change the GoPro web server, so I need to allow / ignore this on the client side. When I make this call using Fiddler as a proxy, Fiddler fixes the problem and my application works as expected. But without the fiddler, I get a protocol violation message.

From a search I did, it can be solved by adding <httpWebRequest useUnsafeHeaderParsing = "true"/>

(see HttpWebRequestElement.UseUnsafeHeaderParsing Property ), but this is Windows 8 and no config file.

One option is to write a custom handler and inject it into the HttpClient ctor, but I'm not sure where to start with my own handler, and this seems like a lot of effort to be inlined.

Is there a simple solution?

0


source to share


2 answers


I haven't tried it myself, but maybe you can change the item by code like this http://social.msdn.microsoft.com/Forums/en-US/ff098248-551c-4da9-8ba5-358a9f8ccc57/how-do- i-enable-useunsafeheaderparsing-from-code-net-20



0


source


Unfortunately, writing your own handler doesn't work either because the system HttpClientHandler

is called before your custom handler when the response is returned.



For Windows Store apps, you can use MessageWebSocket

: I tried something similar for Windows Phone 8.1 Silverlight using StreamSocket

; see How can I accept "insecure" HTTP response headers in a Windows Phone / Store app?

0


source







All Articles