Commit 33d0e410 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Make it possible to test for the non-definition of a http header.

Fixes #1062
parent fe1ae1b5
varnishtest "Ensure that we can test non-existence of headers (#1062)"
server s1 {
rxreq
txresp
} -start
client c1 -connect ${s1_sock} {
txreq
rxresp
expect resp.http.X-Test == <undef>
} -run
...@@ -8,7 +8,7 @@ server s1 { ...@@ -8,7 +8,7 @@ server s1 {
rxreq rxreq
expect req.url == "/bar" expect req.url == "/bar"
expect req.http.Foo == "req.http.Foo" expect req.http.Foo == <undef>
txresp -hdr "Bar: fnry,glyf, FOO ,brok" -hdr "Connection: bar" -body "foobar" txresp -hdr "Bar: fnry,glyf, FOO ,brok" -hdr "Connection: bar" -body "foobar"
} -start } -start
...@@ -21,5 +21,5 @@ client c1 { ...@@ -21,5 +21,5 @@ client c1 {
txreq -url "/bar" -hdr "Foo: bar2" -hdr "Connection: foo, close" txreq -url "/bar" -hdr "Foo: bar2" -hdr "Connection: foo, close"
rxresp rxresp
expect req.http.Bar == "req.http.Bar" expect req.http.Bar == <undef>
} -run } -run
...@@ -81,7 +81,7 @@ client c1 { ...@@ -81,7 +81,7 @@ client c1 {
txreq txreq
rxresp rxresp
expect resp.http.content-encoding == resp.http.content-encoding expect resp.http.content-encoding == <undef>
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 252 expect resp.bodylen == 252
} -run } -run
......
...@@ -18,7 +18,7 @@ client c1 { ...@@ -18,7 +18,7 @@ client c1 {
txreq txreq
rxresp rxresp
expect resp.http.content-encoding == resp.http.content-encoding expect resp.http.content-encoding == <undef>
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 3 expect resp.bodylen == 3
} -run } -run
...@@ -13,7 +13,7 @@ client c1 { ...@@ -13,7 +13,7 @@ client c1 {
txreq txreq
rxresp rxresp
expect resp.bodylen == "3" expect resp.bodylen == "3"
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
txreq -hdr "Accept-encoding: gzip;q=0.1" txreq -hdr "Accept-encoding: gzip;q=0.1"
rxresp rxresp
...@@ -26,13 +26,13 @@ client c1 { ...@@ -26,13 +26,13 @@ client c1 {
txreq -proto HTTP/1.0 txreq -proto HTTP/1.0
rxresp rxresp
expect resp.bodylen == "3" expect resp.bodylen == "3"
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
} -run } -run
client c1 { client c1 {
txreq -req HEAD txreq -req HEAD
rxresp -no_obj rxresp -no_obj
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
txreq -req HEAD -hdr "Accept-encoding: gzip;q=0.1" txreq -req HEAD -hdr "Accept-encoding: gzip;q=0.1"
rxresp -no_obj rxresp -no_obj
......
...@@ -39,12 +39,12 @@ client c1 { ...@@ -39,12 +39,12 @@ client c1 {
# See varnish can gunzip it. # See varnish can gunzip it.
txreq -url /foo -hdr "Accept-Encoding: null" txreq -url /foo -hdr "Accept-Encoding: null"
rxresp rxresp
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
expect resp.bodylen == 4100 expect resp.bodylen == 4100
# See varnish can gunzip it, inside ESI # See varnish can gunzip it, inside ESI
txreq -url /bar -hdr "Accept-Encoding: null" txreq -url /bar -hdr "Accept-Encoding: null"
rxresp rxresp
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
expect resp.bodylen == 4109 expect resp.bodylen == 4109
} -run } -run
...@@ -30,12 +30,12 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { ...@@ -30,12 +30,12 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
client c1 { client c1 {
txreq -url /foo -hdr "Accept-Encoding: gzip" txreq -url /foo -hdr "Accept-Encoding: gzip"
rxresp rxresp
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
expect resp.bodylen == 41 expect resp.bodylen == 41
txreq -url /bar -hdr "Accept-Encoding: gzip" txreq -url /bar -hdr "Accept-Encoding: gzip"
rxresp rxresp
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
expect resp.bodylen == 42 expect resp.bodylen == 42
txreq -url /foobar -hdr "Accept-Encoding: gzip" txreq -url /foobar -hdr "Accept-Encoding: gzip"
...@@ -46,6 +46,6 @@ client c1 { ...@@ -46,6 +46,6 @@ client c1 {
txreq -url /foobar txreq -url /foobar
rxresp rxresp
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
expect resp.bodylen == 43 expect resp.bodylen == 43
} -run } -run
...@@ -6,11 +6,11 @@ varnishtest "Header deletion test" ...@@ -6,11 +6,11 @@ varnishtest "Header deletion test"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/foo" expect req.url == "/foo"
expect req.http.hdr1 == "req.http.hdr1" expect req.http.hdr1 == <undef>
expect req.http.hdr2 == "2" expect req.http.hdr2 == "2"
expect req.http.hdr3 == "req.http.hdr3" expect req.http.hdr3 == <undef>
expect req.http.hdr4 == "4" expect req.http.hdr4 == "4"
expect req.http.hdr5 == "req.http.hdr5" expect req.http.hdr5 == <undef>
expect req.http.hdr6 == "6" expect req.http.hdr6 == "6"
txresp -body "foobar" txresp -body "foobar"
} -start } -start
......
...@@ -3,7 +3,7 @@ varnishtest "Check Range forwarding to backend" ...@@ -3,7 +3,7 @@ varnishtest "Check Range forwarding to backend"
server s1 { server s1 {
rxreq rxreq
expect req.url == "/foo" expect req.url == "/foo"
expect req.http.range == "req.http.range" expect req.http.range == <undef>
txresp \ txresp \
-hdr "Foobar: _barf_" \ -hdr "Foobar: _barf_" \
-body "012345\n" -body "012345\n"
......
...@@ -19,6 +19,6 @@ client c1 { ...@@ -19,6 +19,6 @@ client c1 {
txreq txreq
rxresp rxresp
expect resp.http.bar == "bar, barf: fail" expect resp.http.bar == "bar, barf: fail"
expect resp.http.barf == resp.http.barf expect resp.http.barf == <undef>
expect resp.http.foo == resp.http.foo expect resp.http.foo == <undef>
} -run } -run
...@@ -4,11 +4,11 @@ feature 64bit ...@@ -4,11 +4,11 @@ feature 64bit
server s1 { server s1 {
rxreq rxreq
expect req.http.baz == "req.http.baz" expect req.http.baz == <undef>
txresp -status 201 txresp -status 201
rxreq rxreq
expect req.http.baz == "req.http.baz" expect req.http.baz == <undef>
txresp -status 202 txresp -status 202
rxreq rxreq
...@@ -52,7 +52,7 @@ varnish v1 -arg "-p sess_workspace=1024" -vcl+backend { ...@@ -52,7 +52,7 @@ varnish v1 -arg "-p sess_workspace=1024" -vcl+backend {
"0123456789abcdef" + "0123456789abcdef" + "0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" + "0123456789abcdef" + "0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" + "0123456789abcdef" +
"01234567"; "0123456";
set req.http.baz = "BAZ"; set req.http.baz = "BAZ";
return (pass); return (pass);
} }
......
...@@ -34,12 +34,12 @@ varnish v1 \ ...@@ -34,12 +34,12 @@ varnish v1 \
client c1 { client c1 {
txreq -url "/1" txreq -url "/1"
rxresp rxresp
expect resp.http.Content-Encoding == resp.http.Content-Encoding expect resp.http.Content-Encoding == <undef>
expect resp.bodylen == 22 expect resp.bodylen == 22
txreq -url "/barf" -hdr "Accept-Encoding: gzip" txreq -url "/barf" -hdr "Accept-Encoding: gzip"
rxresp rxresp
expect resp.http.Content-Encoding == resp.http.Content-Encoding expect resp.http.Content-Encoding == <undef>
expect resp.bodylen == 909 expect resp.bodylen == 909
txreq -url "/2" -hdr "Accept-Encoding: gzip" txreq -url "/2" -hdr "Accept-Encoding: gzip"
......
...@@ -24,6 +24,6 @@ client c1 { ...@@ -24,6 +24,6 @@ client c1 {
txreq -url /foobar txreq -url /foobar
rxresp rxresp
expect resp.http.content-encoding == "resp.http.content-encoding" expect resp.http.content-encoding == <undef>
expect resp.bodylen == 43 expect resp.bodylen == 43
} -run } -run
...@@ -175,7 +175,7 @@ http_find_header(char * const *hh, const char *hdr) ...@@ -175,7 +175,7 @@ http_find_header(char * const *hh, const char *hdr)
* Expect * Expect
*/ */
static char * static const char *
cmd_var_resolve(struct http *hp, char *spec) cmd_var_resolve(struct http *hp, char *spec)
{ {
char **hh, *hdr; char **hh, *hdr;
...@@ -207,16 +207,16 @@ cmd_var_resolve(struct http *hp, char *spec) ...@@ -207,16 +207,16 @@ cmd_var_resolve(struct http *hp, char *spec)
hdr = http_find_header(hh, hdr); hdr = http_find_header(hh, hdr);
if (hdr != NULL) if (hdr != NULL)
return (hdr); return (hdr);
return (spec); return ("<undef>");
} }
static void static void
cmd_http_expect(CMD_ARGS) cmd_http_expect(CMD_ARGS)
{ {
struct http *hp; struct http *hp;
char *lhs; const char *lhs;
char *cmp; char *cmp;
char *rhs; const char *rhs;
(void)cmd; (void)cmd;
(void)vl; (void)vl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment