{"id":1184,"date":"2012-06-13T00:49:54","date_gmt":"2012-06-12T15:49:54","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=1184"},"modified":"2012-06-13T01:24:19","modified_gmt":"2012-06-12T16:24:19","slug":"to-parsing-the-postget-request-and-cookie-header-of-varnish-vmod-parsereq","status":"publish","type":"post","link":"https:\/\/blog.xcir.net\/?p=1184","title":{"rendered":"To parsing the POST\/GET request and Cookie header of Varnish (vmod-parsereq)"},"content":{"rendered":"<p>Difficult to access the POST\/GET\/Cookie value in Varnish.<br \/>\nI want more easily to access it.<br \/>\nTherefore, I tried to make a VMOD to parse.<\/p>\n<h3>Feature<\/h3>\n<ul>\n<li>Support POST\/GET request and Cookie header.<\/li>\n<li>Support application\/x-www-form-urlencoded and multipart\/form-data Content-type in POST request.<\/li>\n<li>Can be getting a list of key.<\/li>\n<li>Support Varnish 3.0.1, 3.0.2 , 3.0.3-rc1<\/li>\n<\/ul>\n<h3>How to use<\/h3>\n<p>For example, how to set the response header from the POST key of hoge.<br \/>\nIt&#8217;s a simple.<\/p>\n<pre class=\"brush: plain; \">\n\r\nimport parsereq;\r\n\r\nvcl_recv{\r\n  \/\/please write &quot;parsereq.init();&quot; to 1st line in vcl_recv.\r\n  parsereq.init();\r\n}\r\nvcl_deliver{\r\n  set resp.http.hoge = parsereq.post_header(&quot;hoge&quot;);\r\n}\r\n\n<\/pre>\n<h3>Future plans<\/h3>\n<ul>\n<li>urlencode\/decode<\/li>\n<li>change the value and set to bereq<\/li>\n<li>refactoring<\/li>\n<\/ul>\n<p>I hope that this code is of help to you.<\/p>\n<p>download here.<br \/>\n<a href=\"https:\/\/github.com\/xcir\/libvmod-parsereq\">vmod-parsereq<\/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%3D1184&title=To%20parsing%20the%20POST%2FGET%20request%20and%20Cookie%20header%20of%20Varnish%20%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=1184' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - To parsing the POST\/GET request and Cookie header of Varnish (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=1184' alt='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - To parsing the POST\/GET request and Cookie header of Varnish (vmod-parsereq)' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - To parsing the POST\/GET request and Cookie header of Varnish (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%3D1184&t=To%20parsing%20the%20POST%2FGET%20request%20and%20Cookie%20header%20of%20Varnish%20%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%3D1184&title=To%20parsing%20the%20POST%2FGET%20request%20and%20Cookie%20header%20of%20Varnish%20%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=1184\" data-text=\"To parsing the POST\/GET request and Cookie header of Varnish (vmod-parsereq)\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Difficult to access the POST\/GET\/Cookie value in Varnish. I want more easily to access it. Therefore, I tried  <a href='https:\/\/blog.xcir.net\/?p=1184' 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":[24,3],"tags":[5,34,43],"class_list":["post-1184","post","type-post","status-publish","format-standard","hentry","category-english","category-3","tag-varnish","tag-vmod","tag-vmod_parsereq","category-24-id","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\/1184","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=1184"}],"version-history":[{"count":14,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1184\/revisions"}],"predecessor-version":[{"id":1198,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1184\/revisions\/1198"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}