このチュートリアルに従って、HTTP/2 をサポートする cURL をコンパイルしようとしました。私はDockerを使用しており、私のアプリケーションは Debian を使用する公式の PHP Docker イメージに基づいていますが、 Vagrant VM内で実行されている Ubuntu マシンでも同じ問題が発生しました。
最初は問題ないようです。実際、実行すると、curl --version
私が期待するすべてが表示されます。
curl 7.47.1 (x86_64-pc-linux-gnu) libcurl/7.47.1 OpenSSL/1.0.1k zlib/1.2.8 libidn/1.29 libssh2/1.4.3 nghttp2/1.7.1 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: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets
また、https://nghttp2.orgに問題なく接続できます。
curl --http2 -I https://nghttp2.org
HTTP/2.0 200
date:Mon, 15 Feb 2016 18:02:34 GMT
content-type:text/html
content-length:6680
last-modified:Thu, 11 Feb 2016 14:29:49 GMT
etag:"56bc9add-1a18"
link:</stylesheets/screen.css>; rel=preload; as=stylesheet
accept-ranges:bytes
x-backend-header-rtt:0.000581
server:nghttpx nghttp2/1.8.0-DEV
via:1.1 nghttpx
strict-transport-security:max-age=31536000
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
x-content-type-options:nosniff
問題は、現在 HTTP/2 で実行されているApple の最近再起動されたAPNS プロバイダー APIに接続しようとしたときに始まります。
Mac に Homebrew 経由で curl をインストールしました ( を使用--with-nghttp2
)。次の (予想される) 応答を取得できます。
curl -d 'Hello' --http2 https://api.push.apple.com/3/device/test
{"reason":"Forbidden"}
ただし、Docker イメージ内から同じコマンドを実行しようとすると、次のようになります。
curl -d 'Hello' --http2 https://api.push.apple.com/3/device/test
?@@?HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 504f5354202f332f6465766963652f746573742048545450
なぜこの問題が Apple のサービスに特有のように見えるのか、また状況を改善するために何をする必要があるのか、私にはよくわからない.
どんな助けでも大歓迎です!