Error “curl: (1) Received HTTP/0.9 when not allowed” (SOLVED)
May 2, 2021
cURL is a popular command line utility that supports many network protocols.
curl supports HTTP with numerous options and variations. It can speak HTTP version 0.9, 1.0, 1.1, 2 and 3 depending on build options and the correct command line options.
But when the remote host does respond with HTTP/0.9, curl fails with an error that HTTP/0.9 is not allowed, e.g .:
curl 109.169.23.79:8083 curl: (1) Received HTTP/0.9 when not allowed
The thing is that since curl 7.66.0, HTTP/0.9 is disabled by default. But this is not a problem, as this protocol can be re-enabled with an option.
The --http0.9 option tells curl to handle HTTP version 0.9 response normally.
HTTP/0.9 is a completely headerless response and therefore you can also connect with this to non-HTTP servers and still get a response since curl will simply transparently downgrade - if allowed.
An example of a command with this option:
curl --http0.9 109.169.23.79:8083
What versions of HTTP does cURL support? How to select the HTTP version in cURL
As mentioned, cURL supports the following versions of HTTP: 0.9, 1.0, 1.1, 2, and 3.
The following options are used to select them:
--http0.9
Considered just above
-0, --http1.0
Tells curl to use HTTP version 1.0 instead of using its internally preferred HTTP version.
This option overrides --http1.1 and --http2.
--http1.1
Tells curl to use HTTP version 1.1.
This option overrides -0, --http1.0 and --http2. Added in 7.33.0.
--http2-prior-knowledge
Tells curl to issue its non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade. It requires prior knowledge that the server supports HTTP/2 straight away. HTTPS requests will still do HTTP/2 the standard way with negotiated protocol version in the TLS handshake.
--http2-prior-knowledge requires that the underlying libcurl was built to support HTTP/2. This option overrides --http1.1 and -0, --http1.0 and --http2. Added in 7.49.0.
--http2
Tells curl to use HTTP version 2.
See also --http1.1 and --http3. --http2 requires that the underlying libcurl was built to support HTTP/2. This option overrides --http1.1 and -0, --http1.0 and --http2-prior-knowledge. Added in 7.33.0.
--http3
WARNING: this option is experimental. Do not use in production.
Tells curl to use HTTP version 3 directly to the host and port number used in the URL. A normal HTTP/3 transaction will be done to a host and then get redirected via Alt-SVc, but this option allows a user to circumvent that when you know that the target speaks HTTP/3 on the given host and port.
This option will make curl fail if a QUIC connection cannot be established, it cannot fall back to a lower HTTP version on its own.
See also --http1.1 and --http2. --http3 requires that the underlying libcurl was built to support HTTP/3. This option overrides --http1.1 and -0, --http1.0 and --http2 and --http2-prior-knowledge. Added in 7.66.0.
Related articles:
- How to download a file from a URL and save it on my server (how to avoid running out of RAM when downloading large files) (98.7%)
- Analogue of the --force option in pacman (51.4%)
- How to downgrade to a previous kernel in Arch Linux (51.4%)
- bash: finger: command not found in Arch Linux (RESOLVED) (51.4%)
- How to choose the default Java version in Arch Linux (51.4%)
- How to show all errors in PHP 8 (RANDOM - 51.4%)