curl HTTP/2@Mac
HTTP/2用サーバーを立てるなら、debug用途でcurlでもHTTP/2を使いたい。
環境: OS X EI Capitan 10.11.3
普通にやると
$ curl -I google.com HTTP/1.1 302 Found Cache-Control: private Content-Type: text/html; charset=UTF-8 Location: http://www.google.co.jp/?gfe_rd=cr&ei=mshtV9S9BvLC8geyqZ7QAg Content-Length: 261 Date: Fri, 24 Jun 2016 23:56:10 GMT
http2オプションつければ・・・
$curl -I --http2 google.com curl: (1) Unsupported protocol
バージョン確認すると対応してるプロトコルや機能が見える
$ curl -V curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5 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
ビルドオプションにnghttp2を指定して、curlを再インストール
$ brew reinstall curl -- --with-nghttp2 $ brew link curl --force $ hash -r
FeaturesにHTTP2が追加されてる
$ curl -V curl 7.48.0 (x86_64-apple-darwin15.3.0) libcurl/7.48.0 OpenSSL/1.0.2h zlib/1.2.5 nghttp2/1.10.0 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
HTTP/2が使われる
$ curl -I --http2 https://google.com HTTP/2.0 302 cache-control:private content-type:text/html; charset=UTF-8 location:https://www.google.co.jp/?gfe_rd=cr&ei=ncxtV9W1GbDK8geS5JegAg content-length:262 date:Sat, 25 Jun 2016 00:13:17 GMT alternate-protocol:443:quic alt-svc:quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
https://じゃないとHTTP/2は使われない
$ curl -I --http2 google.com HTTP/1.1 302 Found Cache-Control: private Content-Type: text/html; charset=UTF-8 Location: http://www.google.co.jp/?gfe_rd=cr&ei=ksxtV6X0MKfK8geE5LWgBA Content-Length: 261 Date: Sat, 25 Jun 2016 00:13:06 GMT