httpstatコマンドの使い方


#1 環境
VMware Workstation 14 Player上のゲストマシンを使っています。

```
[root@server ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

[root@server ~]# uname -r
3.10.0-693.el7.x86_64
```

#2 pipのインストール

```
[root@server ~]# curl -kL https://bootstrap.pypa.io/get-pip.py | python
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1622k  100 1622k    0     0   205k      0  0:00:07  0:00:07 --:--:--  480k
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |????????????????????????????????| 1.3MB 986kB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Successfully installed pip-18.1 wheel-0.32.3

[root@server ~]# pip -V
pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
```


#3 httpstatのインストール

```
[root@server ~]#  pip install httpstat
Collecting httpstat
  Downloading https://files.pythonhosted.org/packages/b5/a8/c925a81e0c2c6a32c867c648309aeb744077a5ee95e2f604c7fdcc422577/httpstat-1.2.1-py2-none-any.whl
Installing collected packages: httpstat
Successfully installed httpstat-1.2.1

[root@server ~]# httpstat --version
httpstat 1.2.1
```


#4 httpstatの実行

```
[root@server ~]# httpstat https://www.google.co.jp/
Connected to 216.58.197.3:443 from 192.168.3.4:43664

HTTP/1.1 200 OK
Date: Thu, 27 Dec 2018 10:45:32 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=Shift_JIS
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2018-12-27-10; expires=Sat, 26-Jan-2019 10:45:32 GMT; path=/; domain=.google.co.jp
Set-Cookie: NID=152=Khl4dOoG6TdHn7p6gdA-OOsVCpF0xuyys6kSDPbnDLAAthktlXs28t4iVEh46NH43ImzALRTA8bXybdpHhecJD2CzSXVMyZH7Rqw0mJfffXcVP1BKVC1EvbA3sIZGdQfjIuxGfH4pgxQxTRuUbBJXjhrRpZLh7VBTCLwvYZCl-A; expires=Fri, 28-Jun-2019 10:45:32 GMT; path=/; domain=.google.co.jp; HttpOnly
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
Accept-Ranges: none
Vary: Accept-Encoding
Transfer-Encoding: chunked

Body stored in: /tmp/tmphDEFQY

  DNS Lookup   TCP Connection   TLS Handshake   Server Processing   Content Transfer
[    30ms    |      32ms      |     178ms     |       99ms        |       13ms       ]
             |                |               |                   |                  |
    namelookup:30ms           |               |                   |                  |
                        connect:62ms          |                   |                  |
                                    pretransfer:240ms             |                  |
                                                      starttransfer:339ms            |
                                                                                 total:352ms
```


#5 スピードを表示する方法(HTTPSTAT_SHOW_SPEED=true)

```
[root@server ~]# export HTTPSTAT_SHOW_SPEED=true
[root@server ~]# httpstat https://www.google.co.jp/
Connected to 216.58.196.227:443 from 192.168.3.4:41710

HTTP/1.1 200 OK
Date: Thu, 27 Dec 2018 10:46:48 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=Shift_JIS
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2018-12-27-10; expires=Sat, 26-Jan-2019 10:46:48 GMT; path=/; domain=.google.co.jp
Set-Cookie: NID=152=T-SEnByw3FRMxf-XQMggv8EwU9jVumxkTaAPewJ_prs1LrK29X_DYwD1lGyYTs-vKQaf4z2u21zQ15HhLw8vMfDFfLE1NKZv_sLlyFvGgEhZHHw0s08RLlba5YIU7l1DPoo7CgbMvxd-4kZRGq2LIXN3AfKFJ0RDmvz5faMdkU0; expires=Fri, 28-Jun-2019 10:46:48 GMT; path=/; domain=.google.co.jp; HttpOnly
Alt-Svc: quic=":443"; ma=2592000; v="44,43,39,35"
Accept-Ranges: none
Vary: Accept-Encoding
Transfer-Encoding: chunked

Body stored in: /tmp/tmpr4bMH4

  DNS Lookup   TCP Connection   TLS Handshake   Server Processing   Content Transfer
[    30ms    |      33ms      |     154ms     |       106ms       |       14ms       ]
             |                |               |                   |                  |
    namelookup:30ms           |               |                   |                  |
                        connect:63ms          |                   |                  |
                                    pretransfer:217ms             |                  |
                                                      starttransfer:323ms            |
                                                                                 total:337ms

★speed_download: 33.4 KiB/s, speed_upload: 0.0 KiB/s
```