1

For several days I have been trying to establish communication with the server using HttpWebRequest. I noticed that server isn't compliant with the protocol specification of the http in RFC. Therefore, I set tru in App.config:

<httpWebRequest useUnsafeHeaderParsing = "true" />

After doing this, I received a 400 answer. I noticed that I can communicate using curl software. I set the same headings in my code - with no result.

Finally, I noticed that the order of the host header is a problem. If the host header is after POST / HTTP / 1.1, the server responds is OK, but if it is at the end of all headers, then I get the code 400.

Didn't work:

POST / HTTP / 1.1
User-Agent: curl / 7.52.1
Accept: * / *
Content-Type: text / xml; charset = ISO-8859-1
SOAPAction: ...
Host: 10.10.10.147

It works:

POST / HTTP / 1.1
Host: 10.10.10.147
User-Agent: curl / 7.52.1
Accept: * / *
Content-Type: text / xml; charset = ISO-8859-1
SOAPAction: ...

Is there any possibility to change the order of headers using HttpWebRequest?

Wojtek
  • 11
  • 1
  • It also works fine if there is no host header, so I tried: webRequest.Headers.Remove("Host"); – Wojtek Dec 05 '17 at 18:55
  • How can you read in https://stackoverflow.com/questions/246859/http-1-0-vs-1-1 A host header is not required in http 1.0. I set the version to 1.0, and the host header is still sent and can't be deleted. – Wojtek Dec 05 '17 at 19:22

0 Answers0