第三十回スパルタンプログラミング
何がしたいか?何が問題か?を意識して変なとこでぐだぐだ考えないこと! 30分悩んで分からなかったら、早めにヘルプを出す。
メーカのソフトパッチをパッケージ化して、テストして展開の試行をした週。疲れた。 翌週は全面展開なので緊張する。準備は万端だ。だがきんちょーる。
夕飯は太平楽の麻婆麺。飯がいいなと思いながら、あえて麺にした。旨いんだなこれが。
スキーに行き過ぎて週末プログラムをしてない二月の、疲れと緊張を抱いたままのそんな土曜日。
やりたいこと
- httpsで応答を返す。
やったこと
調査
SSL_acceptがSSL_ERROR_WANT_READを吐くのは
If the underlying BIO is non-blocking, SSL_accept() will also return when the underlying BIO could not satisfy the needs of SSL_accept() to continue the handshake, indicating the problem by the return value -1. In this case a call to SSL_get_error() with the return value of SSL_accept() will yield SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE. The calling process then must repeat the call after taking appropriate action to satisfy the needs of SSL_accept(). The action depends on the underlying BIO. When using a non-blocking socket, nothing is to be done, but select() can be used to check for the required condition. When using a buffering BIO, like a BIO pair, data must be written into or retrieved out of the BIO before being able to continue.
ブラウザがGETのGのみを送ってくることがある。
超ハマった!自分のバグかと思って悩みまくった。実際には、ブラウザが送っていた。
http://stackoverflow.com/questions/16995008/is-it-reasonable-to-assume-that-all-http-headers-of-a-single-http-message-arri http://security.stackexchange.com/questions/63215/why-does-firefox-split-https-request
対応
SSLReadLine内で吸収する。
- 何も読むものがないときはSSL_pending(ssl)は0、行末でない。ただし、直前の読み込みの扱いはSSL_ERROR_WANT_READ(これは違うケースがあるかも)
- splitされたときはSSL_pending(ssl)は0、行末でない。ただし、直前の読み込みの扱いはSSL_ERROR_NONE
なので、SSL_pending(ssl)は0、行末でないかつSSL_ERROR_NONEのときsplitと判断して対応した。
この対応が終わったことで、平文でできてたところまでにはなった。
ALPN 15/03/02
HTTP/2はALPNを使う(draft16 3.1)ので、まず使えるようにする。
使い方
http://qiita.com/tatsuhiro-t/items/dea3fb279ad265681049
このおかげでリストはとれるようになった。
connection prefaceの取り方
しかーし、
PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n
がとれねぇ。なんで?nghttp2に学ぶ。