Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

cURLでincludeオプションをつけるとレスポンスヘッダを見ることができる

cURLでレスポンスヘッダを表示する場合、includeオプションを付けてやります。

実際のところ

前回の記事でJSONを吐き出すパートを作りました。
includeオプションをつけて表示すると、この通り

$ curl --include http://localhost:8080/api/status
HTTP/1.0 200 OK
Date: Tue, 27 Sep 2016 15:03:09 GMT
Server: WSGIServer/0.2 CPython/3.4.3
Content-Length: 50
Content-Type: application/json

{"status": "online", "time": "09-28_00:03:09_JST"}

通常のHTMLなら、こんな感じ

$ curl --include http://localhost:8080/time
HTTP/1.0 200 OK
Date: Tue, 27 Sep 2016 15:03:25 GMT
Server: WSGIServer/0.2 CPython/3.4.3
Content-Length: 148
Content-Type: text/html; charset=UTF-8


<h1>jade sample</h1>
<p>var : <p>09-28_00:03:25_JST</p></p>
<p>Jade is outdated.  Use Pug! </p>
<li>https://pugjs.org/api/getting-started.html</li>

レスポンスコード等、一部情報だけみたい場合

shuzo-kino.hateblo.jp

参考もと