سؤال

I am trying to receive HTTP content from a small embedded Chinese device. The device's inbuilt web server accepts headers but does not return any on the response.

ie

Raw Response: (2 lines, 1 is the XML the second is blank \n)

<?xml version="1.0" encoding="utf-8"?><document><userkey>key</userkey> <machinemode>1</machinemode><serial>0000</serial><unitname>Device</unitname><version>1</version></document>\n

Fiddler will not show the response at all. Using HttpWebRequest and WebClient yields no results as there are no headers in the response and this results in an exception. Some of the research I have done points to adding the useUnsafeHeaderParsing into the application config (and/or setting it programmatically). This does not work at all. I still receive

System.Net.WebException was unhandled Message=The server committed a protocol violation. Section=ResponseStatusLine Source=System StackTrace: at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)

Is there a work around for this? Without using Sockets/TCPClient is there an alternative way of receiving data from a server that provides no headers?

هل كانت مفيدة؟

المحلول

I couldn't figure out how to get WebClient nor HttpWebRequest to work for accessing the response in such a scenario, so unfortunately i think you're left with TcpClient :(

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top