{"id":1168,"date":"2012-06-10T23:38:33","date_gmt":"2012-06-10T14:38:33","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=1168"},"modified":"2012-06-12T18:09:08","modified_gmt":"2012-06-12T09:09:08","slug":"varnish%e3%81%a7post%e3%83%bbcookie%e3%83%bbget%e3%82%92%e6%89%b1%e3%81%86%e3%81%9f%e3%82%81%e3%81%aevmod%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9fvmod-parsereq","status":"publish","type":"post","link":"https:\/\/blog.xcir.net\/?p=1168","title":{"rendered":"Varnish\u3067POST\u30fbCOOKIE\u30fbGET\u3092\u6271\u3046\u305f\u3081\u306eVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f(vmod-parsereq)"},"content":{"rendered":"<p>\u3053\u306e\u524d\u306e<a href=\"http:\/\/blog.xcir.net\/index.php\/2012\/06\/varnish%e3%81%a7post%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e6%89%b1%e3%81%86%e3%81%9f%e3%82%81%e3%81%aevmod%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9fvmod-parsepost\/\" title=\"Varnish\u3067POST\u30c7\u30fc\u30bf\u3092\u6271\u3046\u305f\u3081\u306eVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f(vmod-parsepost)\">\u30a8\u30f3\u30c8\u30ea<\/a>\u3067POST\u3092\u6271\u3046VMOD\u3092\u4f5c\u3063\u3066\u307f\u305f\u3068\u3044\u3046\u306e\u3092\u4e0a\u3052\u305f\u306e\u3067\u3059\u304c<br \/>\n\u3042\u306e\u5f8c\u3001\u4f7f\u3063\u3066\u304f\u308c\u305f\u4eba\u3068\u304b\u304b\u3089\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u5909\u3048\u308b\u3068\uff72\uff72\uff96\uff70\uff72\uff72\uff96\uff70\u3068\u8a00\u308f\u308c\u305f\u306e\u3067<br \/>\nreq.http.*\u306b\u683c\u7d0d\u3059\u308b\u306e\u3067\u306f\u306a\u304f<a href=\"https:\/\/www.varnish-cache.org\/vmod\/curl\">vmod_curl<\/a>\u306e\u3088\u3046\u306b\u826f\u3044\u611f\u3058\u306b\u4f7f\u3044\u3084\u3059\u304f\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u3060\u3051\u3058\u3083\u3064\u307e\u3089\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u304a\u307e\u3051\u3067GET\u3068COOKIE\u306b\u5bfe\u5fdc\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306e\u7279\u5fb4\u306f\u4ee5\u4e0b\u3067\u3059\u3002<br \/>\n\u30fbapplication\/x-www-form-urlencoded\u3068multipart\/form-data\u4e21\u65b9\u306b\u5bfe\u5fdc<br \/>\n\u30fbGET\u30fbPOST\u30fbCOOKIE\u306b\u5bfe\u5fdc<br \/>\n\u30fb\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30ad\u30fc\u306e\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3000\u30a4\u30f3\u30e9\u30a4\u30f3C\u3068\u4f75\u7528\u3059\u308b\u3053\u3068\u3067\u3059\u3079\u3066\u306eGET\u30fbPOST\u30fbCOOKIE\u306e\u30ad\u30fc\u306b\u5bfe\u3057\u3066\u7279\u5b9a\u306e\u5024<br \/>\n\u3000\uff08\u653b\u6483\u3063\u307d\u3044\u30b3\u30fc\u30c9\u306a\u3069\uff09\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u306a\u3069\u306e\u30c1\u30a7\u30c3\u30af\u304c\u5bb9\u6613\u3067\u3059<\/p>\n<p>\u4f7f\u3044\u65b9\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<br \/>\n\u305f\u3068\u3048\u3070POST\u3067hoge\u3068\u3044\u3046\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u3059\u308b\u5834\u5408\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; \">\n\r\nimport parsereq;\r\n\r\nvcl_recv{\r\n  parsereq.init();\/\/\u5fc5\u305avcl_recv\u306e\u5148\u982d\u3067\u5ba3\u8a00\u3059\u308b\r\n}\r\nvcl_deliver{\r\n  set resp.http.hoge = parsereq.post_header(&quot;hoge&quot;);\r\n}\r\n\n<\/pre>\n<p>\u524d\u306b\u6bd4\u3079\u3066\u308f\u304b\u308a\u3084\u3059\u304f\u306a\u3063\u305f\u3093\u3067\u306f\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u307e\u305f\u4eca\u56de\u306f\u5024\u306furlencode\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u751f\u306e\u5024\u3067\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u6539\u884c\u3092\u542b\u3080\u53ef\u80fd\u6027\u304c\u3042\u308b\u5834\u5408\u306fresp.http.*\u306a\u3069\u306b\u542b\u3081\u308b\u3068<br \/>\n\u610f\u56f3\u3057\u306a\u3044\u7d50\u679c\u304c\u8d77\u304d\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<br \/>\n\u30b3\u30b3\u3089\u3078\u3093\u306fencode\/decode\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3057\u3066\u89e3\u6c7a\u3059\u308b\u4e88\u5b9a\u3067\u3059\u306e\u3067<br \/>\n\u5c11\u3057\u5f85\u3063\u3066\u3082\u3089\u3048\u308b\u3068\u3042\u308a\u304c\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u95a2\u6570\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p><strong>VOID init()<\/strong><br \/>\n\u3000\u521d\u671f\u5316\u3092\u884c\u3046\u3002<br \/>\n\u3000\u5fc5\u305avcl_recv\u306e\u5148\u982d\u3067\u547c\u3073\u51fa\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><strong>INT errcode()<\/strong><br \/>\n\u3000\u521d\u671f\u5316\u306e\u7d50\u679c\u3092\u53d7\u3051\u53d6\u308b<\/p>\n<pre class=\"brush: plain; \">\n\r\n(\u6210\u529f) 2   content-type\u304c\u7121\u3044\u304b\u30b5\u30dd\u30fc\u30c8\u5916\r\n(\u6210\u529f) 1   \u30d1\u30fc\u30b9\u306b\u6210\u529f\r\n(\u5931\u6557) -1  sess_workspace\u306e\u6b8b\u308a\u30b5\u30a4\u30ba\u304c\u306a\u304f\u306a\u3063\u3066\u30e1\u30e2\u30ea\u78ba\u4fdd\u306b\u5931\u6557\r\n(\u5931\u6557) -2  content-length\u304c\u7121\u3044\r\n(\u5931\u6557) -3  \u8aad\u307f\u53d6\u308c\u308b\u30b5\u30a4\u30ba\u304ccontent-length\u4ee5\u4e0b\r\n\n<\/pre>\n<p><strong>STRING post_header(STRING)<br \/>\nSTRING get_header(STRING)<br \/>\nSTRING cookie_header(STRING)<\/strong><br \/>\n\u3000\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b<\/p>\n<p><strong>STRING post_body()<br \/>\nSTRING get_body()<br \/>\nSTRING cookie_body()<\/strong><br \/>\n\u3000POST,GET,COOKIE\u306e\u751f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97<\/p>\n<p><strong>STRING post_read_keylist()<br \/>\nSTRING get_read_keylist()<br \/>\nSTRING cookie_read_keylist()<\/strong><br \/>\n\u3000\u547c\u3073\u51fa\u3059\u3054\u3068\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30ad\u30fc\u3092\u53d6\u5f97\u3059\u308b<\/p>\n<pre class=\"brush: plain; \">\n\r\n\/\/req\r\n\/?name1=a&amp;name2=b\r\n\r\n\/\/vcl\r\nvcl_deliver{\r\n  set resp.http.n1 = parsereq.get_read_keylist();\r\n  set resp.http.n2 = parsereq.get_read_keylist();\r\n  \/\/nothing\r\n  set resp.http.n3 = parsereq.get_read_keylist();\r\n}\r\n\r\n\/\/return\r\nn1: name2\r\nn2: name1\r\n\n<\/pre>\n<p><strong>VOID post_seek_reset()<br \/>\nVOID get_seek_reset()<br \/>\nVOID cookie_seek_reset()<\/strong><br \/>\n\u3000\u524d\u8ff0\u306eXXX_read_keylist\u3067\u3001\u4f55\u51e6\u307e\u3067\u53d6\u5f97\u3057\u305f\u304b\u3092\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u3002<br \/>\n\u3000\u30ea\u30bb\u30c3\u30c8\u3057\u3066XXX_read_keylist\u3092\u547c\u3073\u51fa\u3059\u3068\u307e\u305f\u6700\u521d\u304b\u3089\u8aad\u307f\u51fa\u3059\u3002<\/p>\n<p>\u4eca\u5f8c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u308b3.0.3\u306b\u3064\u3044\u3066\u3082<br \/>\nrc1\u306b\u304a\u3044\u3066\u6b63\u5e38\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u591a\u5206\u52d5\u304f\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u57fa\u672c\u7684\u306b3.0.1\u4ee5\u964d\u3067\u3042\u308c\u3070\u52d5\u304d\u307e\u3059\u3002<\/p>\n<p>\u4eca\u5f8c\u306e\u4e88\u5b9a\u306f<br \/>\n\u30fb\u30a8\u30f3\u30b3\u30fc\u30c9\u30fb\u30c7\u30b3\u30fc\u30c9\u30ed\u30b8\u30c3\u30af\u8ffd\u52a0<br \/>\n\u30fb\u5024\u306e\u5909\u66f4\u3057\u305f\u5f8c\u306b\u30ea\u30d3\u30eb\u30c9\u3057\u3066\u305d\u308c\u3092\u4f7f\u3046<br \/>\n\u30fb\u30b3\u30fc\u30c9\u304c\u82e5\u5e72\u30ab\u30aa\u30b9\u3063\u3066\u308b\u306e\u3067\u7dba\u9e97\u306b\u3059\u308b<br \/>\n\u30fbetc&#8230;<br \/>\n\u3067\u3059<\/p>\n<p><a href=\"https:\/\/github.com\/xcir\/libvmod-parsereq\">download\u306f\u3053\u3061\u3089<\/a><\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D1168&title=Varnish%E3%81%A7POST%E3%83%BBCOOKIE%E3%83%BBGET%E3%82%92%E6%89%B1%E3%81%86%E3%81%9F%E3%82%81%E3%81%AEVMOD%E3%82%92%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F%28vmod-parsereq%29' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_hatena_users\"><a href='\/\/b.hatena.ne.jp\/entry\/https:\/\/blog.xcir.net\/?p=1168' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Varnish\u3067POST\u30fbCOOKIE\u30fbGET\u3092\u6271\u3046\u305f\u3081\u306eVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f(vmod-parsereq)' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='\/\/b.hatena.ne.jp\/entry\/image\/https:\/\/blog.xcir.net\/?p=1168' alt='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Varnish\u3067POST\u30fbCOOKIE\u30fbGET\u3092\u6271\u3046\u305f\u3081\u306eVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f(vmod-parsereq)' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Varnish\u3067POST\u30fbCOOKIE\u30fbGET\u3092\u6271\u3046\u305f\u3081\u306eVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f(vmod-parsereq)'   class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D1168&t=Varnish%E3%81%A7POST%E3%83%BBCOOKIE%E3%83%BBGET%E3%82%92%E6%89%B1%E3%81%86%E3%81%9F%E3%82%81%E3%81%AEVMOD%E3%82%92%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F%28vmod-parsereq%29' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_linkedin\"><a href='\/\/www.linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D1168&title=Varnish%E3%81%A7POST%E3%83%BBCOOKIE%E3%83%BBGET%E3%82%92%E6%89%B1%E3%81%86%E3%81%9F%E3%82%81%E3%81%AEVMOD%E3%82%92%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F%28vmod-parsereq%29' title='LinkedIn \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/linkedin.png' alt='LinkedIn \u306b\u30b7\u30a7\u30a2' title='LinkedIn \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/blog.xcir.net\/?p=1168\" data-text=\"Varnish\u3067POST\u30fbCOOKIE\u30fbGET\u3092\u6271\u3046\u305f\u3081\u306eVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f(vmod-parsereq)\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u524d\u306e\u30a8\u30f3\u30c8\u30ea\u3067POST\u3092\u6271\u3046VMOD\u3092\u4f5c\u3063\u3066\u307f\u305f\u3068\u3044\u3046\u306e\u3092\u4e0a\u3052\u305f\u306e\u3067\u3059\u304c \u3042\u306e\u5f8c\u3001\u4f7f\u3063\u3066\u304f\u308c\u305f\u4eba\u3068\u304b\u304b\u3089\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u5909\u3048\u308b\u3068\uff72\uff72\uff96\uff70\uff72\uff72\uff96\uff70\u3068\u8a00\u308f\u308c\u305f\u306e\u3067 req.http.*\u306b\u683c\u7d0d\u3059\u308b\u306e\u3067\u306f\u306a\u304fvmod_curl <a href='https:\/\/blog.xcir.net\/?p=1168' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[5,34,43],"class_list":["post-1168","post","type-post","status-publish","format-standard","hentry","category-3","tag-varnish","tag-vmod","tag-vmod_parsereq","category-3-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1168"}],"version-history":[{"count":15,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1168\/revisions"}],"predecessor-version":[{"id":1183,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1168\/revisions\/1183"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}