Skip to content

Instantly share code, notes, and snippets.

@xcir
Created November 19, 2012 16:57
Show Gist options
  • Save xcir/4111859 to your computer and use it in GitHub Desktop.
Save xcir/4111859 to your computer and use it in GitHub Desktop.
https://github.com/xcir/libvmod-parsereq/tree/future-iterate
--vcl
import std;
import parsereq;
sub test{
parsereq.next_offset(req);
if(parsereq.current_key(req) != "hoge"){
set req.http.hoge = req.http.hoge + parsereq.current_key(req) + "("+parsereq.size(req,parsereq.current_key(req)) +"):";
set req.http.hoge = req.http.hoge + parsereq.param(req, parsereq.current_key(req)) + " ";
}
}
sub vcl_recv{
if(1 == 0){
call test;
}
parsereq.init();
set req.http.hoge= "[start1]";
C{
Vmod_Func_parsereq.iterate(sp, "req", (const char*)VGC_function_test);
}C
set req.http.hoge = req.http.hoge + "[end]";
std.syslog(6,req.http.hoge);
}
--ret
Nov 20 03:02:00 localhost varnishd[6249]: [start1]Host(18):192.168.1.199:6081 Connection(10):keep-alive Cache-Control(9):max-age=0 User-Agent(108):Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11 Accept(63):text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding(17):gzip,deflate,sdch Accept-Language(23):ja,en-US;q=0.8,en;q=0.6 Accept-Charset(29):Shift_JIS,utf-8;q=0.7,*;q=0.3 Cookie(21):aaaa=bbbb; cccc=sssss X-VMOD-PARSEREQ-PTR(15):140350670795136 [end]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment