Skip to content

Instantly share code, notes, and snippets.

@mapk0y
Last active September 22, 2016 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapk0y/dd7df4398164f6214a03affbff7e4a91 to your computer and use it in GitHub Desktop.
Save mapk0y/dd7df4398164f6214a03affbff7e4a91 to your computer and use it in GitHub Desktop.
curl で色々表示する(参考: http://akuwano.hatenablog.jp/entry/20120503/1335994486
#!/bin/bash
set -e
set -u
usage() {
echo >&2 "Usage:"
echo >&2 " ${0} URL"
exit
}
if [ "$#" -ne 1 ]; then
usage
fi
URL=${1}
curl -sL --verbose -o /dev/null ${URL} -w \
"
url_effective : %{url_effective}
http_code : %{http_code}
http_connect : %{http_connect}
time_total : %{time_total}
time_namelookup : %{time_namelookup}
time_connect : %{time_connect}
time_appconnect : %{time_appconnect}
time_pretransfer : %{time_pretransfer}
time_redirect : %{time_redirect}
time_starttransfer : %{time_starttransfer}
size_download : %{size_download}
size_upload : %{size_upload}
size_header : %{size_header}
size_request : %{size_request}
speed_download : %{speed_download}
speed_upload : %{speed_upload}
"

出力サンプル

$ ./measure_http_get.sh https://www.google.co.jp
* Rebuilt URL to: https://www.google.co.jp/
* Hostname was NOT found in DNS cache
*   Trying 216.58.196.227...
* Connected to www.google.co.jp (216.58.196.227) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Server hello (2):
{ [data not shown]
* SSLv3, TLS handshake, CERT (11):
{ [data not shown]
* SSLv3, TLS handshake, Server key exchange (12):
{ [data not shown]
* SSLv3, TLS handshake, Server finished (14):
{ [data not shown]
* SSLv3, TLS handshake, Client key exchange (16):
} [data not shown]
* SSLv3, TLS change cipher, Client hello (1):
} [data not shown]
* SSLv3, TLS handshake, Finished (20):
} [data not shown]
* SSLv3, TLS change cipher, Client hello (1):
{ [data not shown]
* SSLv3, TLS handshake, Finished (20):
{ [data not shown]
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256
* Server certificate:
*        subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.google.com
*        start date: 2016-09-14 08:26:35 GMT
*        expire date: 2016-12-07 08:19:00 GMT
*        subjectAltName: www.google.co.jp matched
*        issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
*        SSL certificate verify ok.
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: www.google.co.jp
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Thu, 22 Sep 2016 22:29:38 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 https://www.google.com/support/accounts/answer/151657?hl=en for more info."
* Server gws is not blacklisted
< Server: gws
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: NID=87=UJnRntBeCBnR9ltcM_v3wtyqTo5mAjww7PezD87dlmeoOHgLetw-Chcx57PQ8yRaKTyxZw3JUroXjrMylZ58CxW2SnNDealoFGI8Qnhf7KeoqS4mV2JQouetxFB9PaAz; expires=Fri, 24-Mar-2017 22:29:38 GMT; path=/; domain=.google.co.jp; HttpOnly
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
< Accept-Ranges: none
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< 
{ [data not shown]
* Connection #0 to host www.google.co.jp left intact

url_effective      : https://www.google.co.jp/
http_code          : 200
http_connect       : 000
time_total         : 0.133
time_namelookup    : 0.014
time_connect       : 0.016
time_appconnect    : 0.060
time_pretransfer   : 0.060
time_redirect      : 0.000
time_starttransfer : 0.130
size_download      : 11000
size_upload        : 0
size_header        : 693
size_request       : 80
speed_download     : 82413.000
speed_upload       : 0.000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment