Cookie ちゃんとできてるかどうか調べたいときに LiveHTTPHeaders 開いたりするのは面倒なのでもっと楽にできないかなーと思って https://addons.mozilla.org/ja/firefox/addon/6683 ってのを見つけたけど、それ curl でもできるんじゃね?と思って調べたらできたのでメモ。 http://www.big.or.jp/~crane/cocoa/0800_internet/curl/index.html がわかりやすかった。
- -b (--cookie) file
- -c (--cookie-jar) file
[kyanny@kyanny-laptop2 ~/daily/2009-10-19] # Set-Cookie ヘッダがはかれる $ curl -I http://www.livedoor.com/ HTTP/1.1 200 OK Date: Mon, 19 Oct 2009 05:48:50 GMT Server: Apache/2.0.63 (Unix) mod_perl/2.0.3 Perl/v5.8.6 Set-Cookie: ucd=vEwMaowsS79D557YCfpZPZIBO5CxTIIE; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:48:50 GMT Set-Cookie: ucd_sig=sa5iEtp5sPK%2FiroExiiT97Gk1g0%3A1255931330; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:48:50 GMT Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding,User-Agent X-XRDS-Location: https://auth.livedoor.com/openid/server.xrds [kyanny@kyanny-laptop2 ~/daily/2009-10-19] # もう一度 Set-Cookie ヘッダがはかれる。値は違う $ curl -I http://www.livedoor.com/ HTTP/1.1 200 OK Date: Mon, 19 Oct 2009 05:48:53 GMT Server: Apache/2.0.63 (Unix) mod_perl/2.0.3 Perl/v5.8.6 Set-Cookie: ucd=b2dbFHpYDD3M7Rf3ZO9O8w3RXRAW6qeU; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:48:53 GMT Set-Cookie: ucd_sig=%2FhQDOrhDDEZELWM1e4%2B%2FyidiuXk%3A1255931333; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:48:53 GMT Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding,User-Agent X-XRDS-Location: https://auth.livedoor.com/openid/server.xrds [kyanny@kyanny-laptop2 ~/daily/2009-10-19] # Cookie がまだ保存されてないので Set-Cookie ヘッダがはかれる $ curl -I http://www.livedoor.com/ -b cookie.txt -c cookie.txt HTTP/1.1 200 OK Date: Mon, 19 Oct 2009 05:49:02 GMT Server: Apache/2.0.63 (Unix) mod_perl/2.0.3 Perl/v5.8.6 Set-Cookie: ucd=9lxce9gnbCol8tIQ0a0T1LR89Gs7ixJR; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:49:02 GMT Set-Cookie: ucd_sig=UXZYb5oI9aWbOWTXJI4DLg7h4Zk%3A1255931342; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:49:02 GMT Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding,User-Agent X-XRDS-Location: https://auth.livedoor.com/openid/server.xrds [kyanny@kyanny-laptop2 ~/daily/2009-10-19] # さっきの Cookie が保存されてるので Set-Cookie ヘッダははかれない $ curl -I http://www.livedoor.com/ -b cookie.txt -c cookie.txt HTTP/1.1 200 OK Date: Mon, 19 Oct 2009 05:49:03 GMT Server: Apache/2.0.63 (Unix) mod_perl/2.0.3 Perl/v5.8.6 Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding,User-Agent X-XRDS-Location: https://auth.livedoor.com/openid/server.xrds [kyanny@kyanny-laptop2 ~/daily/2009-10-19] # Cookie ヘッダがリクエスト時にくっついてれば Set-Cookie ははかれない $ curl -I http://www.livedoor.com/ -b cookie.txt HTTP/1.1 200 OK Date: Mon, 19 Oct 2009 05:56:56 GMT Server: Apache/2.0.63 (Unix) mod_perl/2.0.3 Perl/v5.8.6 Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding,User-Agent X-XRDS-Location: https://auth.livedoor.com/openid/server.xrds [kyanny@kyanny-laptop2 ~/daily/2009-10-19] # Cookie ヘッダがリクエストについてないので Set-Cookie ヘッダがまたはかれる $ curl -I http://www.livedoor.com/ -c cookie.txt HTTP/1.1 200 OK Date: Mon, 19 Oct 2009 05:57:33 GMT Server: Apache/2.0.63 (Unix) mod_perl/2.0.3 Perl/v5.8.6 Set-Cookie: ucd=KVQxrY0BJKBrKoVw7qn7iPYg4tQ8xYb5; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:57:33 GMT Set-Cookie: ucd_sig=EJqagKpDkTMrUHeDqxhMo3UVo50%3A1255931853; domain=livedoor.com; path=/; expires=Sat, 17-Apr-2010 05:57:33 GMT Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Vary: Accept-Encoding,User-Agent X-XRDS-Location: https://auth.livedoor.com/openid/server.xrds