1

I know this shouldn't matter, but the host I am dealing with keeps rejecting my requests because of the order of headers. The request sent through my code looks like this:

POST https://www.expedia.co.in/Hotel-Search-Data HTTP/1.1
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: application/json, text/javascript
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36
Connection: keep-alive
Host: www.expedia.co.in
Content-Length: 112

destination=Surat, India&regionId=3290&startDate=02/07/2018&endDate=03/07/2018&adults=1&hsrIdentifier=HSR&Page=1

The request which works is this:

POST https://www.expedia.co.in/Hotel-Search-Data HTTP/1.1
Host: www.expedia.co.in
Connection: keep-alive
Content-Length: 112
Accept: application/json, text/javascript
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5

destination=Surat, India&regionId=3290&startDate=02/07/2018&endDate=03/07/2018&adults=1&hsrIdentifier=HSR&Page=1

Is it possible to change the order of headers? I have already tried it using WebClient and HTTPClient, neither worked.

Anon
  • 133
  • 1
  • 9

1 Answers1

0

The content-length is wrong.

The body should not start with &

A POST should not contain a query string; remove ?haha=false.

Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
  • I removed the & from the POST body, corrected the content-length and removed the query string, but the request still doesn't work. I know its very strange but, the response does depend on the order of the headers. EDIT: included the actual working and non-working requests. – Anon Jul 01 '18 at 10:52