Created
December 18, 2016 16:25
-
-
Save gquintard/f2c472090e1ec7d3a42d0b9430717ce3 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
varnishtest "Long vcl/backend names" | |
server s1 { | |
rxreq | |
txresp -status 301 -hdr "Location: http://bar.example.com/bar" | |
expect req.http.host == "foo.example.com" | |
expect req.url == "/foo" | |
rxreq | |
txresp -status 301 -hdr "Location: http://baz.example.com/baz" | |
expect req.http.host == "bar.example.com" | |
expect req.url == "/bar" | |
rxreq | |
txresp -hdr "final: true" | |
expect req.http.host == "baz.example.com" | |
expect req.url == "/baz" | |
} -start | |
varnish v1 -vcl+backend { | |
import std; | |
sub vcl_backend_response { | |
if (beresp.status == 301 && beresp.http.location ~ "^https?://[^/]+/") { | |
set bereq.http.host = regsuball(beresp.http.location, "^https?://([^/]+)/.*", "\1"); | |
set bereq.url = regsuball(beresp.http.location, "^https?://([^/]+)", ""); | |
return (retry); | |
} | |
} | |
} -start | |
client c1 { | |
txreq -url "/foo" -hdr "host: foo.example.com" | |
rxresp | |
expect resp.status == 200 | |
expect resp.http.final == "true" | |
} -run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment