Created
February 10, 2021 16:50
-
-
Save aondio/634bd32abbf89d5368ff4d219356f15c to your computer and use it in GitHub Desktop.
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 CUSTOM request" | |
server s1 { | |
rxreq | |
txresp -status 601 | |
} -start | |
server s2 { | |
rxreq | |
txresp -status 602 -reason "PURGE ok" | |
expect req.url == "/foo" | |
expect req.method == "PURGE" | |
} -start | |
varnish v1 -vcl { | |
import http; | |
backend default { | |
.host = "${s1_addr}"; | |
.port = "${s1_port}"; | |
} | |
sub vcl_recv { | |
if (req.method == "PURGE") { | |
return (purge); | |
} | |
} | |
sub vcl_deliver { | |
http.init(1); | |
http.debug_print(1); | |
http.req_set_url(1, "http://${s2_addr}:${s2_port}" + req.url); | |
http.req_set_method(1, req.http.method); | |
http.req_send(1); | |
http.resp_wait(1); | |
set resp.http.vmodhttp-ready = http.resp_is_ready(1); | |
set resp.http.vmodhttp-status = http.resp_get_status(1); | |
set resp.http.vmodhttp-reason = http.resp_get_reason(1); | |
set resp.http.vmodhttp-errorcode = http.resp_get_errorcode(1); | |
} | |
} -start | |
client c1 { | |
txreq -url "/foo" -hdr "method: PURGE" | |
rxresp | |
expect resp.status == 601 | |
expect resp.http.vmodhttp-ready == "true" | |
expect resp.http.vmodhttp-status == "602" | |
expect resp.http.vmodhttp-reason == "PURGE ok" | |
expect resp.http.vmodhttp-errorcode == "0" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment