beresp.http.Set-Cookie
または resp.http.Set-Cookie
の値は正規表現を使って取得していたが、安全に取り出せる関数があることを知ったのでメモ
よく問題になるのが以下のようなSet-Cookie
が複数あるレスポンスの場合
HTTP/1.1 200 OK Cache-Control: max-age=60 Content-Type: text/html; charset=utf-8 Content-Length: 80806 Accept-Ranges: bytes Date: Tue, 11 Aug 2015 19:00:04 GMT Age: 123 Connection: keep-alive Set-Cookie: one=a; httponly; secure Set-Cookie: two=b or not to b; httponly
こういうレスポンスのSet-Cookieの値は正規表現でうまく取得できないことがあるらしい
そこで、以下の関数を使うと安全に取得できるとのことなので、これからはこれを使うようにする
setcookie.get_value_by_name(resp, "name")
set resp.http.X-One = setcookie.get_value_by_name(resp, "one"); set resp.http.X-Two = setcookie.get_value_by_name(resp, "two");