Skip to content

Instantly share code, notes, and snippets.

@mrchoke
Last active May 5, 2024 08:52
Show Gist options
  • Save mrchoke/f22177f4daa8aefda559b0891c36ce06 to your computer and use it in GitHub Desktop.
Save mrchoke/f22177f4daa8aefda559b0891c36ce06 to your computer and use it in GitHub Desktop.
cURL brew formula support HTTP/3

How to

Remove old curl

brew uninstall --ignore-dependencies curl

Download the curl ruby install script

wget https://gist.githubusercontent.com/mrchoke/f22177f4daa8aefda559b0891c36ce06/raw/85d811e2d21bb4d4599ad092f88e2e971f23b473/curl.rb

Install curl via that script from the latest git repos

brew install --HEAD -s curl.rb

Tell your cli to use the curl version just installed (if you're using zsh, othwerise you might need ~/.bashrc)

Intel CPU

echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc

M1/M2 CPU

echo 'export PATH="/opt/homebrew/curl/bin:$PATH"' >> ~/.zshrc

Reload your config

exec zsh

or

exec bash

Try curl on any HTTP/3 enabled sites.

curl -Iv --http3 https://google.com

Credit

Original article

class Curl < Formula
desc "Get a file from an HTTP, HTTPS or FTP server with HTTP/3 support"
homepage "https://curl.se"
# Don't forget to update both instances of the version in the GitHub mirror URL.
url "https://curl.se/download/curl-8.7.1.tar.bz2"
mirror "https://github.com/curl/curl/releases/download/curl-8_7_1/curl-8.7.1.tar.bz2"
mirror "http://fresh-center.net/linux/www/curl-8.7.1.tar.bz2"
mirror "http://fresh-center.net/linux/www/legacy/curl-8.7.1.tar.bz2"
sha256 "05bbd2b698e9cfbab477c33aa5e99b4975501835a41b7ca6ca71de03d8849e76"
license "curl"
livecheck do
url "https://curl.se/download/"
regex(/href=.*?curl[._-]v?(.*?)\.t/i)
end
head do
url "https://github.com/curl/curl.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
keg_only :provided_by_macos
depends_on "pkg-config" => :build
depends_on "brotli"
depends_on "libidn2"
depends_on "libnghttp2"
depends_on "libnghttp3"
depends_on "libssh2"
depends_on "openldap"
depends_on "openssl@3"
depends_on "rtmpdump"
depends_on "zstd"
uses_from_macos "krb5"
uses_from_macos "zlib"
def install
tag_name = "curl-#{version.to_s.tr(".", "_")}"
if build.stable? && stable.mirrors.grep(/github\.com/).first.exclude?(tag_name)
odie "Tag name #{tag_name} is not found in the GitHub mirror URL! " \
"Please make sure the URL is correct."
end
system "./buildconf" if build.head?
args = %W[
--disable-debug
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--with-ssl=#{Formula["openssl@3"].opt_prefix}
--with-openssl=#{Formula["openssl@3"].opt_prefix}
--with-nghttp3=#{Formula["libnghttp3"].opt_prefix}
--with-openssl-quic
--without-ca-bundle
--without-ca-path
--with-ca-fallback
--with-default-ssl-backend=openssl
--with-libidn2
--with-librtmp
--with-libssh2
--without-libpsl
]
args << if OS.mac?
"--with-gssapi"
else
"--with-gssapi=#{Formula["krb5"].opt_prefix}"
end
system "./configure", *args
system "make", "install"
system "make", "install", "-C", "scripts"
libexec.install "scripts/mk-ca-bundle.pl"
end
test do
# Fetch the curl tarball and see that the checksum matches.
# This requires a network connection, but so does Homebrew in general.
filename = (testpath/"test.tar.gz")
system "#{bin}/curl", "-L", stable.url, "-o", filename
filename.verify_checksum stable.checksum
system libexec/"mk-ca-bundle.pl", "test.pem"
assert_predicate testpath/"test.pem", :exist?
assert_predicate testpath/"certdata.txt", :exist?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment