How to use curl command with http/2 on MacOS X

www.laut‮t‬uri.com
How to use curl command with http/2 on MacOS X

To use the curl command with HTTP/2 on macOS, you will need to ensure that curl is compiled with HTTP/2 support. Most versions of curl available on macOS include HTTP/2 support by default.

To use curl with HTTP/2, you can simply specify the --http2 flag when making the request:

curl --http2 https://www.example.com/

This will send an HTTP/2 request to the URL https://www.example.com/. If the server supports HTTP/2, the request will be sent over an HTTP/2 connection.

You can also use the -k flag to disable certificate verification if the server uses a self-signed certificate:

curl --http2 -k https://www.example.com/

This can be useful for testing purposes, but it is not recommended for production environments as it can compromise the security of the connection.

You can also use other curl options, such as -X to specify the HTTP method, -d to send data in the request body, and -H to set HTTP headers. For example:

curl --http2 -X POST -d "some data" -H "Content-Type: application/json" https://www.example.com/

This will send an HTTP/2 POST request with the data "some data" in the request body and the Content-Type header set to application/json.

Created Time:2017-10-29 22:08:40  Author:lautturi