10

I made request using curl, the response says that HTTP Version not supported, error 505. What are the steps to make HTTP Version supported.

After googling i get, the i should use curl --http2.0 to make it work, but my curl version is not supporting that option, as it is added in curl 7.33, whereas i am using curl with version: curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2

Now, should i upgrade my curl or is there any other way to make it supported or am i missing something in my request(sorry, but i am not able to show the request).

If i need to upgrade it, then please specify me the way how to upgrade curl to version 7.33.0, i am not getting any proper way to do it.

Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81
  • I think you need to upgrade your cURL. Curious what server you're talking to that is HTTP 2.0. – Jonathon Reinhart Nov 21 '13 at 06:44
  • actually, i am assuming that it may be using HTTP 2.0, I dont know exactly what to do for getting out of that error – Mehul Thakkar Nov 21 '13 at 06:51
  • http://stackoverflow.com/questions/2757404/http-request-failed-http-1-1-505-http-version-not-supported-error this might help – linux_fanatic Nov 21 '13 at 08:52
  • @linux_fanatic : i have seen that question, but that is for php, whereas i am using curl commandline in linux, also that is not giving me proper idea, about what to do – Mehul Thakkar Nov 21 '13 at 09:00
  • 2
    As some answers have alluded to (and as was my case), you may first want to confirm there are no spaces in the url. If there are, replace them with `%20` – jgreen Sep 10 '18 at 19:34

6 Answers6

27

for me the problem was mistake in the url (i had space there) after this issue it turn out that the curl complaining about bad http version was false alarm.

oak
  • 2,898
  • 2
  • 32
  • 65
  • 4
    I had exactly the same problem - there was a space in the URL. I just need to remember that (unlike browser) curl passes the URL literally in the HTTP request. Replace spaces with `%20` and encode other special characters too.. js functions `encodeURI()` and `encodeURIComponent()` may be helpful here (as many implementations in other languages too) – TMG Nov 20 '17 at 15:12
  • but why this is just failing in curl if I used postman to call the same with spaces it worked pretty much well. – Indrajeet Gour Mar 15 '20 at 19:15
  • 1
    @YouAreAwesome it might happend because the `postman` change the encoding of char like that while the `curl in bash` cannot make this kind of changes – oak Mar 17 '20 at 13:04
12

I got the same error today with Imperva Rest API curl commands.

Turned out that the URL that I was using had some path / (variables containing spaces in it's value) http://.../.../some path/or/some thing here/resource/sites and it didn't allow spaces.

To fix the issue, I used %20 to replace space characters (as per Imperva REST API v11.5 doc): http://.../.../some%20path/or/some%20thing%20here/resource/sites and then it worked.

AKS
  • 16,482
  • 43
  • 166
  • 258
  • Yes. In my case in a Shell script I was using quotes around the input that preserves spaces by default – SidJ Sep 19 '17 at 07:36
2

this is a confusion created by curl error message. however this issue has nothing to be with HTTP version, most of the time is the space inside the curl URL. e.g. "adc.com/adc?a=hi there", so to fix this one just need to escape those chars according to rfc3986, like "adc.com/adc?a=hi%20there".

linehrr
  • 1,668
  • 19
  • 24
1

curl defaults to using HTTP 1.1 (which -v and --trace will show you), so if that is non-supported you probably need to switch to HTTP 1.0 using the --http1.0 option.

http 2 is hardly used in the wild yet by servers and is only supported by very recent curl versions .

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
1

For me it was while passing a half-coded "url" to Curl, particularly spaces were not encoded into "%20", while other staff was encoded properly. someone should either pass a "url" fully decoded or fully encoded.

coucou8949
  • 41
  • 1
  • 7
0

I guess this is more or less just a message telling you that you http response is not well-formed in some way or may be in an unsupported http format.

I've had the same problem today: a server application I am woirking on would return an incomplete status message in its header, like

HTTP/1.1  500

instead of

HTTP/1.1 500 Internal Server Error

and curl would complain about an unsupported HTTP version. So it seems the message after the status code has to be filled in order to be valid http. Makes sense, but the message was a bit misleading. It is not necessarily about the HTTP version, it just says: malformed when validated against the http version spec.

Joachim Tuchel
  • 447
  • 2
  • 10