backend default { .host = "127.0.0.1"; .port = "80"; } // Intialization C{ #include "/usr/src/wurfl/wurfl.h" int is_mobile; }C // simple subroutine that fetches the useragent, checks if its a mobile device and // sets the backend-request header accordingly sub detectmobile { C{ char *ua = VRT_GetHdr(sp, HDR_REQ, "\013User-Agent:"); is_mobile = wurfl_ismobile(ua); VRT_SetHdr(sp, HDR_BEREQ, "\011X-Mobile:", (is_mobile == 1)?"yes":"no", vrt_magic_string_end); }C } // Miss, pass and pipe all make a request to the backend sub vcl_miss { call detectmobile; return(fetch); } sub vcl_pipe { call detectmobile; return(pipe); } sub vcl_pass { call detectmobile; return(pass); } // Deliver sets the header to the response to the client as well sub vcl_deliver { C{ VRT_SetHdr(sp, HDR_RESP, "\011X-Mobile:", (is_mobile == 1)?"yes":"no", vrt_magic_string_end); }C }