「spdylay」の版間の差分

提供: セキュリティ
移動: 案内検索
(SPDYサーバにspdycatコマンドでアクセスする)
 
行143: 行143:
 
           x-xss-protection: 1; mode=block
 
           x-xss-protection: 1; mode=block
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
=== spdyd ===
 
=== spdyd ===
 
spdyd は、[[SPDY]]に対応したサーバプログラムです。spdyのクライアントを開発するときのテストサーバとして使用できます。
 
spdyd は、[[SPDY]]に対応したサーバプログラムです。spdyのクライアントを開発するときのテストサーバとして使用できます。

2014年11月15日 (土) 16:44時点における最新版

spdylay とは、C言語によるGoogle SPDY プロトコルの実験的な実装です。このライブラリは、SPDYバージョン2,3,3.1のフレーミングレイヤーの実装を提供します。SPDYに対応したサーバに対して curlコマンドのようにアクセスできるspdycatコマンドが提供されます。

読み方

spdylay
すぴーでぃ れい
spdycat
すぴーでぃきゃっと

概要

spdylayは、SPDYのC言語のライブラリとSPDYに関連するコマンドを提供します。 spdylayで提供されるspdycatやspdydのコマンドは、SPDY対応のサーバやクライアントの開発のテストに役立ちます。

インストール

FreeBSDにインストールする場合

pkgコマンドでインストールする場合

sudo pkg install spdylay

Ubuntu

自分でビルドしなければならないようです。

CentOS

自分でビルドしなければならないようです。

spdylay-1.3.1でインストールされるファイル

spdylay-1.3.1:
        /usr/local/bin/shrpx
        /usr/local/bin/spdycat
        /usr/local/bin/spdycli
        /usr/local/bin/spdyd
        /usr/local/etc/shrpx.conf.sample
        /usr/local/include/spdylay/spdylay.h
        /usr/local/include/spdylay/spdylayver.h
        /usr/local/lib/libspdylay.a
        /usr/local/lib/libspdylay.so
        /usr/local/lib/libspdylay.so.7
        /usr/local/lib/libspdylay.so.7.1.1
        /usr/local/libdata/pkgconfig/libspdylay.pc
        /usr/local/share/doc/spdylay/README.rst
        /usr/local/share/licenses/spdylay-1.3.1/LICENSE
        /usr/local/share/licenses/spdylay-1.3.1/MIT
        /usr/local/share/licenses/spdylay-1.3.1/catalog.mk

使い方

spdycat

コマンドラインオプション

Usage: spdycat [-Oansv23] [-t <SECONDS>] [-w <WINDOW_BITS>] [--cert=<CERT>]
               [--key=<KEY>] [--no-tls] [-d <FILE>] [-m <N>] [-p <PROXY_HOST>]
               [-P <PROXY_PORT>] <URI>...
 
OPTIONS:
    -v, --verbose      Print debug information such as reception/
                       transmission of frames and name/value pairs.
    -n, --null-out     Discard downloaded data.
    -O, --remote-name  Save download data in the current directory.
                       The filename is dereived from URI. If URI
                       ends with '/', 'index.html' is used as a
                       filename. Not implemented yet.
    -2, --spdy2        Only use SPDY/2.
    -3, --spdy3        Only use SPDY/3.
    --spdy3-1          Only use SPDY/3.1.
    -t, --timeout=<N>  Timeout each request after <N> seconds.
    -w, --window-bits=<N>
                       Sets the initial window size to 2**<N>.
    -a, --get-assets   Download assets such as stylesheets, images
                       and script files linked from the downloaded
                       resource. Only links whose origins are the
                       same with the linking resource will be
                       downloaded.
    -s, --stat         Print statistics.
    -H, --header=<HEADER>
                       Add a header to the requests. Use This
                       option repeatedly to add multiple headers.
                       The hard coded headers (e.g., :method) can
                       be overridden by specifying same header
                       field name and its replacement value.
                       Example: -H':method: HEAD'
    --cert=<CERT>      Use the specified client certificate file.
                       The file must be in PEM format.
    --key=<KEY>        Use the client private key file. The file
                       must be in PEM format.
    --no-tls           Disable SSL/TLS. Use -2, -3 or --spdy3-1 to
                       specify SPDY protocol version to use.
    -d, --data=<FILE>  Post FILE to server. If - is given, data
                       will be read from stdin.
    -m, --multiply=<N> Request each URI <N> times. By default, same
                       URI is not requested twice. This option
                       disables it too.
    -p, --proxy=<HOST> Use this host as a SPDY proxy
    -P, --proxy-port=<PORT>
                       Use this as the port of the SPDY proxy if
                       one is set
    --color            Force colored log output.

SPDYサーバにspdycatコマンドでアクセスする

curlライクにSPDYに対応したサーバにアクセスする場合は、以下の通りです。

$ spdycat https://www.google.com/

SPDYプロトコルの詳細を表示するには、-v オプションを使用します。

$ spdycat -v https://www.google.com/

Googleにアクセスした例です。SPDY 3.1 が選択されて通信が行われています。

$ spdycat -v https://www.google.co.jp/
[  0.038] NPN select next protocol: the remote server offers:
          * spdy/5a1
          * h2-14
          * spdy/3.1
          * spdy/3
          * http/1.1
          NPN selected the protocol: spdy/3.1
[  0.053] Handshake complete
[  0.053] recv SETTINGS frame <version=3, flags=0, length=20>
          (niv=2)
          [4(1):100]
          [7(0):65536]
[  0.054] recv WINDOW_UPDATE frame <version=3, flags=0, length=8>
          (stream_id=0, delta_window_size=983040)
[  0.054] send SYN_STREAM frame <version=3, flags=1, length=219>
          (stream_id=1, assoc_stream_id=0, pri=3)
          :host: www.google.co.jp
          :method: GET
          :path: /
          :scheme: https
          accept-encoding: gzip, deflate
          user-agent: spdylay/1.3.1
[  0.124] recv SYN_REPLY frame <version=3, flags=0, length=578>
          (stream_id=1)
          :status: 200 OK
          :version: HTTP/1.1
          alternate-protocol: 443:quic,p=0.01
          cache-control: private, max-age=0
          content-type: text/html; charset=Shift_JIS
          date: Sun, 02 Nov 2014 05:10:31 GMT
          expires: -1
          p3p: CP="This is not a P3P policy!
	  See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
          server: gws
          set-cookie: PREF=ID=XXXXXXXXXXXXXXXX:FF=0:TM=0000000000:LM=0000000000:S=XXXXXXXXXXXXXXXX; expires=T
ue, 01-Nov-2016 05:10:31 GMT; path=/; domain=.google.co.jp
          set-cookie: NID=00=XXXXXXX; expires=Mon, 04-May-2015 05:10:31 GMT; path=/; domain=.google.co.jp; HttpOnly
          x-frame-options: SAMEORIGIN
          x-xss-protection: 1; mode=block

spdyd

spdyd は、SPDYに対応したサーバプログラムです。spdyのクライアントを開発するときのテストサーバとして使用できます。

コマンドラインオプション

Usage: spdyd [-23DVhv] [-d <PATH>] [--no-tls] <PORT> [<PRIVATE_KEY> <CERT>]
 
OPTIONS:
    -D, --daemon       Run in a background. If -D is used, the
                       current working directory is changed to '/'.
                       Therefore if this option is used, -d option
                       must be specified.
    -V, --verify-client
                       The server sends a client certificate
                       request. If the client did not return a
                       certificate, the handshake is terminated.
                       Currently, this option just requests a
                       client certificate and does not verify it.
    -d, --htdocs=<PATH>
                       Specify document root. If this option is
                       not specified, the document root is the
                       current working directory.
    -v, --verbose      Print debug information such as reception/
                       transmission of frames and name/value pairs.
    -2, --spdy2        Only use SPDY/2.
    -3, --spdy3        Only use SPDY/3.
    --spdy3-1          Only use SPDY/3.1.
    --no-tls           Disable SSL/TLS. Use -2, -3 or --spdy3-1 to
                       specify SPDY protocol version to use.
    --color            Force colored log output.
    -h, --help         Print this help.

spdydでサーバを起動する

spdyd コマンドを使用して、4443ポートでサーバを起動します。

spdyd --spdy3-1 --no-tls 4443

冗長に出力する場合には、-vオプションを使用します。

spdyd --spdy3-1 --no-tls 4443 -v

クライアントとしてspdycatを実行します。

spdycat --spdy3-1 --no-tls http://localhost:4443/

存在しないページにアクセスすると404を返してくれます。

$ spdycat --spdy3-1 --no-tls http://localhost:4443/
<html><head><title>404 Not Found</title></head><body><h1>404 Not
Found</h1><hr><address>spdyd spdylay/1.3.1 at port
4443/address></body></html>

関連項目