Skip to content

Instantly share code, notes, and snippets.

@rezan
Created September 1, 2017 22:22
Show Gist options
  • Save rezan/3ecf0a8e1540b021adcdbbe4b477108a to your computer and use it in GitHub Desktop.
Save rezan/3ecf0a8e1540b021adcdbbe4b477108a to your computer and use it in GitHub Desktop.
vmod-http backend fetch
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