Created
October 23, 2012 15:52
-
-
Save xcir/3939606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VMOD | |
https://github.com/xcir/libvmod-parsereq/tree/future-iterate | |
----------------------- | |
--vcl | |
import std; | |
import parsereq; | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "81"; | |
} | |
sub test{ | |
parsereq.next_offset(get); | |
set req.http.hoge = req.http.hoge + parsereq.current_key(get) + ":"; | |
set req.http.hoge = req.http.hoge + parsereq.param(get, parsereq.current_key(get)) + " "; | |
} | |
sub test2{ | |
parsereq.next_offset(get); | |
set req.http.hoge2 = req.http.hoge2 + parsereq.current_key(get) + ":"; | |
set req.http.hoge2 = req.http.hoge2 + parsereq.param(get, parsereq.current_key(get)) + " "; | |
} | |
sub vcl_recv{ | |
if(1 == 0){ | |
call test; | |
call test2; | |
} | |
parsereq.init(); | |
set req.http.hoge= "[start1]"; | |
C{ | |
Vmod_Func_parsereq.iterate(sp, "get", (const char*)VGC_function_test); | |
}C | |
set req.http.hoge = req.http.hoge + "[end]"; | |
set req.http.hoge2= "[start2]"; | |
C{ | |
Vmod_Func_parsereq.iterate(sp, "get", (const char*)VGC_function_test2); | |
}C | |
set req.http.hoge2 = req.http.hoge2 + "[end]"; | |
std.syslog(6,req.http.hoge); | |
std.syslog(6,req.http.hoge2); | |
} | |
----------------------- | |
http://192.168.1.199:6081/?x=aa&y=bb | |
--result | |
Nov 18 20:35:34 localhost varnishd[12870]: [start1]y:bb x:aa [end] | |
Nov 18 20:35:34 localhost varnishd[12870]: [start2]y:bb x:aa [end] | |
----------------------- | |
http://192.168.1.199:6081/?x=aa&y=bb&z=cc | |
--result | |
Nov 18 20:35:21 localhost varnishd[12870]: [start1]z:cc y:bb x:aa [end] | |
Nov 18 20:35:21 localhost varnishd[12870]: [start2]z:cc y:bb x:aa [end] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment