Created
September 1, 2017 22:22
-
-
Save rezan/3ecf0a8e1540b021adcdbbe4b477108a to your computer and use it in GitHub Desktop.
vmod-http backend fetch
This file contains hidden or 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
varnishtest "Test HTTP vmod Varnish callback" | |
server s1 { | |
rxreq | |
txresp -status 200 | |
expect req.url == "/123" | |
expect req.http.Test1 == "2" | |
rxreq | |
txresp -status 200 | |
expect req.url == "/" | |
expect req.http.Test1 == "2" | |
} -start | |
varnish v1 -vcl+backend { | |
import http; | |
sub vcl_recv { | |
set req.http.X-url = http.varnish_url("/123"); | |
} | |
sub vcl_backend_fetch { | |
http.init(1); | |
http.debug_print(1); | |
http.req_copy_headers(1); | |
http.req_set_url(1, bereq.http.X-url); | |
http.req_send(1); | |
http.resp_wait(1); | |
if (!http.req_is_loop(1) && http.resp_get_status(1) != 200) { | |
return(abandon); | |
} | |
} | |
} -start | |
client c1 { | |
txreq -url "/" -hdr "Test1: 2" | |
rxresp | |
expect resp.status == 200 | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment