cURL is one of most powerful tools for testing HTTP traffic. We typically use cURL to interact with HTTP APIs or test websites.
Although cURL supports HTTP/2, the version that’s installed on macOS Sierra does not. Read Update.
If you try to use the --http2
flag, you’ll receive the following error:
curl: (1) Unsupported protocol |
Fortunately, we can use another installation from Homebrew alongside the default version. To do so, just type the following command in the Terminal window (assuming you already have Homebrew installed):
$ brew install curl —with-nghttp2 |
That’s it.
Keep in mind that this installation does not replace the default curl in the system and this can be a good or bad thing for you.
If you want to keep things separately, you’re done as you can always call the 2nd curl by typing its full path:
If you check the version of the two in this example:
curl 7.51.0 (x86_64-apple-darwin16.0) libcurl/7.51.0 SecureTransport zlib/1.2.8 |
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp |
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets |
$ /usr/local/opt/curl/bin/curl --version |
curl 7.54.0 (x86_64-apple-darwin16.6.0) libcurl/7.54.0 OpenSSL/1.0.2l zlib/1.2.8 nghttp2/1.23.1 |
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp |
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy |
If you want to set the curl you installed from Homebrew as the default, keep reading.
Set Homebrew cURL as the Default
There are several ways to set the new version as your default curl, but I believe the best and safest way to do it was already suggested at the end of installation process.
Notice that after installing the curl from Homebrew you’ll see a warning and instruction. If you missed it, it will look similar to this:

######################################################################## 100.0% |
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/curl/7.54.0 --with-==> make install==> |
This formula is keg-only, which means it was not symlinked into /usr/local, |
because macOS already provides this software and installing another version in |
parallel can cause all kinds of trouble. |
If you need to have this software first in your PATH run: |
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile |
For compilers to find this software you may need to set: |
LDFLAGS: -L/usr/local/opt/curl/lib |
CPPFLAGS: -I/usr/local/opt/curl/include |
For pkg-config to find this software you may need to set: |
PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig |
Just following the instruction provided, type in the following:
$ echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile |
You need to restart terminal and this time if you call curl without the full path, it will run the Homebrew version.
If you need to refer back to the default macOS version, just edit your ~/.bash_profile file by typing the following command:
$ sudo nano ~/.bash_profile |
Look for this line:
export PATH= "/usr/local/opt/curl/bin:$PATH" |
and comment it out like so:
# export PATH="/usr/local/opt/curl/bin:$PATH" |
And press CTRL-X and Yes to exit and save it.
Now you can test it using —http2 flag:
Update
Update on 5/21/2019: There are two updates that render this post obsolete.
First update is that the version of curl installed on macOS now supports HTTP/2.
The second update is that Homebrew has removed the –with-nghttp2 option from curl which makes the instructions not accurate.
You can still follow the instructions above for Homebrew version of curl only if you substitute it with the curl-openssl and its corresponding path instead.
So you can uninstall Homebrew curl by running the following:
Then install curl-openssl by running the following:
$ brew install curl-openssl |
That’s it. You don’t even need to specify any flag such as --with-nghttp2
on the curl-openssl install. It will just work. You just need to pay attention to the path where the curl is installed. It is
/usr/local/opt/curl-openssl/bin/curl |
The latest comparison between the two versions of curl:
curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1 |
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp |
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy |
$ /usr/local/opt/curl-openssl/bin/curl --version |
curl 7.65.0 (x86_64-apple-darwin18.6.0) libcurl/7.65.0 OpenSSL/1.0.2r zlib/1.2.11 brotli/1.0.7 c-ares/1.15.0 libssh2/1.8.2 nghttp2/1.38.0 librtmp/2.3 |
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp |
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets |
Further Reading
brew install curl –with-nghttp2 errors saying “invalid option: –with-nghttp2”
- 安装kubuctl
安装和设置kubectl 使用Kubernetes命令行工具kubectl在Kubernetes上部署和管理应用程序.使用kubectl,可以检查集群资源; 创建,删除和更新组件. 以下是安装kube ...
- Fuchsia OS入门官方文档
Fuchsia Pink + Purple == Fuchsia (a new Operating System) Welcome to Fuchsia! This document has ever ...
- Swift 3 and OpenGL on Linux and macOS with GLFW
https://solarianprogrammer.com/2016/11/19/swift-opengl-linux-macos-glfw/ Swift 3 and OpenGL on Linux ...
- 在macOS Sierra 10.12搭建PHP开发环境
macOS Sierra 11.12 已经帮我们预装了 Ruby.PHP(5.6).Perl.Python 等常用的脚本语言,以及 Apache HTTP 服务器.由于 nginx 既能作为 HTTP ...
- How to convert webp to png/jpg/gif in MacOS
Environment I'm using OS X 10.11.4 and have homebrew 1.0.5 installed. Introduction I recently downlo ...
- MacOS X Terminal中设置代理
MacOS X中,即使在网络设置中配置了代理连接,Terminal中也不能访问不可描述的东西,需要额外设置. 我用的是Shadowsocks,使用privoxy搭建了本地的代理服务器,地址是http: ...
- macOS 安装 wget
适用于macOS Sierra Apple Store下载安装Xcode 安装Homebrew包管理,类似于Ubuntu下的apt-get: 终端下输入 ruby -e "$(curl -f ...
- 在MacOS和iOS系统中使用OpenCV
在MacOS和iOS系统中使用OpenCV 前言 OpenCV 是一个开源的跨平台计算机视觉库,实现了图像处理和计算机视觉方面的很多通用算法. 最近试着在 MacOS 和 iOS 上使用 OpenCV ...
- luarocks在macOS系统上的安装
luarocks是基于lua开发的一个包管理工具,所以在安装luarocks之前需要先安装lua(见博客同目录下“lua在MacOS系统上的安装”).具体的安装步骤如下: 1.源码安装部署luaroc ...
- [转]在MacOS和iOS系统中使用OpenCV
OpenCV 是一个开源的跨平台计算机视觉库,实现了图像处理和计算机视觉方面的很多通用算法. 最近试着在MacOS和iOS上使用OpenCV,发现网上关于在MacOS和iOS上搭建OpenCV的资料很 ...
随机推荐
- docker安装过程 - 下载mysql
1. 下载必要的包 sudo yum install -y yum-utils device-mapper-persistent-data lvm2 2. 指定虚拟机去哪里安装 docker sudo ...
- 09-react的组件传值 props
// 组件传值 props 接收传递过来的数据 import ReactDom from "react-dom" import { Component } from "r ...
- 8. REM解释一下
rem (root em )是 c3 新增的相对单位 ,相对的是html根元素,动态变化自己的大小 : 补充: em 也是相对单位,相对的是父元素来动态设置自己大小 : px 是绝对单位,是相对于屏幕 ...
- AI五子棋_08 五子棋落子规则对应的价值
AI五子棋 第八步 恭喜你到达第八步! 利用前一步得到的棋型分析结果,考察每一个可能落子的位置,给每一个可能的位置打分,将棋子落在分数最高的位置上.根据经验,我们可以总结出下面的落子规则: 1. 致胜 ...
- att&ck学习笔记1
一.环境搭建 1.1环境搭建测试 最近想要开始学习内网渗透,搜集了一些教程,准备先实验一个vulnstack靶机,熟悉一下内网渗透操作再学习基础知识. 靶场下载地址:http://vulnstack. ...
- 【JVM第3课】运行时数据区
运行时数据区结构图如下: 可分为 5 个区域,分别是方法区.堆区.虚拟机栈.本地方法栈.程序计数器.这里大概介绍一下各个模块的作用,会在后面的文章展开讲. 类加载子系统会把类信息加载到方法区,程序运行 ...
- Next.js 与 Node.js 全栈应用开发:API设计、数据库连接、身份验证 | 2024版
书接上回,到目前为止,您的应用程序只有一个主页.让我们学习如何使用布局和页面创建更多路线. 在本章之中我们需要讨论: dashboard使用文件系统路由创建路由. 了解创建新路线段时文件夹和文件的作用 ...
- Tomcat弱口令上传war包
Tomcat弱口令上传war包 思路: 利用弱口令登录管理页面 ---> 部署war包 ---> getshell 环境: vulhub靶场:tomcat/tomcat8 启动 ...
- Python中函数或者类对象带()与不带()的区别——闭包和函数返回时的常见现象
Python中函数或者类对象带()与不带()的区别-----闭包和函数返回时的常见现象 - 函数不带括号时,调用的是这个函数本身 ,是整个函数体,是一个函数对象,不需等该函数执行完成,返回一个已定义函 ...
- luasql使用问题记录:module 'luasql.mysql' not found
安装版本 # lua -v Lua 5.3.4 Copyright (C) 1994-2017 Lua.org, PUC-Rio # apisix version /usr/local/openres ...