GET request with curl. No errors, but Content-Length equals 0
Asked Answered
D

3

7

Simple GET request with curl returns empty body (Content-Length: 0):

curl -v https://www.flyorientthai.com/booking/en/index.php

On the other hand wget can handle that url just fine:

wget https://www.flyorientthai.com/booking/en/index.php

What's wrong with curl?

Donnetta answered 23/5, 2015 at 13:11 Comment(3)
Maybe server requires certain HTTP headers that curl doesn't normally send but wget doesPerreault
@MJafarMash you're absolutely right :) 'Connection: Keep-Alive' header was missing with curl request and turned out it was critical.Donnetta
What kind of broken server is this. Keep-Alive is implicit with HTTP/1.1, so this header would be redundant. But yes, using curl -v -H "Connection: keep-alive" gives the expected response while without the header not.Turanian
D
0

Turned out 'Connection: Keep-Alive' header is required. It's added by default to request with wget but not with curl.

Donnetta answered 24/5, 2015 at 10:36 Comment(0)
S
0

For anyone using "Copy as cURL" in the Chrome developer tools network tab to generate a curl command — one of the lines in the generated curl command is a header that looks something like...

-H 'If-None-Match: W/"18f6a6-6p8AL7X/p71IhN/WztZm60Aue4k"'

That causes the server to return an empty 304 response if nothing's changed. Just whip it out.

Statecraft answered 13/7, 2021 at 23:6 Comment(0)
A
-2

Let's try "Content-Type: application/x-www-form-urlencodeds"

Argillite answered 26/5, 2015 at 3:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.