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 {
rxreq
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"
} -start
......@@ -21,5 +21,5 @@ client c1 {
txreq -url "/bar" -hdr "Foo: bar2" -hdr "Connection: foo, close"
rxresp
expect req.http.Bar == "req.http.Bar"
expect req.http.Bar == <undef>
} -run
......@@ -81,7 +81,7 @@ client c1 {
txreq
rxresp
expect resp.http.content-encoding == resp.http.content-encoding
expect resp.http.content-encoding == <undef>
expect resp.status == 200
expect resp.bodylen == 252
} -run
......
......@@ -18,7 +18,7 @@ client c1 {
txreq
rxresp
expect resp.http.content-encoding == resp.http.content-encoding
expect resp.http.content-encoding == <undef>
expect resp.status == 200
expect resp.bodylen == 3
} -run
......@@ -13,7 +13,7 @@ client c1 {
txreq
rxresp
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"
rxresp
......@@ -26,13 +26,13 @@ client c1 {
txreq -proto HTTP/1.0
rxresp
expect resp.bodylen == "3"
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
} -run
client c1 {
txreq -req HEAD
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"
rxresp -no_obj
......
......@@ -39,12 +39,12 @@ client c1 {
# See varnish can gunzip it.
txreq -url /foo -hdr "Accept-Encoding: null"
rxresp
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 4100
# See varnish can gunzip it, inside ESI
txreq -url /bar -hdr "Accept-Encoding: null"
rxresp
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 4109
} -run
......@@ -30,12 +30,12 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend {
client c1 {
txreq -url /foo -hdr "Accept-Encoding: gzip"
rxresp
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 41
txreq -url /bar -hdr "Accept-Encoding: gzip"
rxresp
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 42
txreq -url /foobar -hdr "Accept-Encoding: gzip"
......@@ -46,6 +46,6 @@ client c1 {
txreq -url /foobar
rxresp
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 43
} -run
......@@ -6,11 +6,11 @@ varnishtest "Header deletion test"
server s1 {
rxreq
expect req.url == "/foo"
expect req.http.hdr1 == "req.http.hdr1"
expect req.http.hdr1 == <undef>
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.hdr5 == "req.http.hdr5"
expect req.http.hdr5 == <undef>
expect req.http.hdr6 == "6"
txresp -body "foobar"
} -start
......
......@@ -3,7 +3,7 @@ varnishtest "Check Range forwarding to backend"
server s1 {
rxreq
expect req.url == "/foo"
expect req.http.range == "req.http.range"
expect req.http.range == <undef>
txresp \
-hdr "Foobar: _barf_" \
-body "012345\n"
......
......@@ -19,6 +19,6 @@ client c1 {
txreq
rxresp
expect resp.http.bar == "bar, barf: fail"
expect resp.http.barf == resp.http.barf
expect resp.http.foo == resp.http.foo
expect resp.http.barf == <undef>
expect resp.http.foo == <undef>
} -run
......@@ -4,11 +4,11 @@ feature 64bit
server s1 {
rxreq
expect req.http.baz == "req.http.baz"
expect req.http.baz == <undef>
txresp -status 201
rxreq
expect req.http.baz == "req.http.baz"
expect req.http.baz == <undef>
txresp -status 202
rxreq
......@@ -52,7 +52,7 @@ varnish v1 -arg "-p sess_workspace=1024" -vcl+backend {
"0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" + "0123456789abcdef" +
"0123456789abcdef" +
"01234567";
"0123456";
set req.http.baz = "BAZ";
return (pass);
}
......
......@@ -34,12 +34,12 @@ varnish v1 \
client c1 {
txreq -url "/1"
rxresp
expect resp.http.Content-Encoding == resp.http.Content-Encoding
expect resp.http.Content-Encoding == <undef>
expect resp.bodylen == 22
txreq -url "/barf" -hdr "Accept-Encoding: gzip"
rxresp
expect resp.http.Content-Encoding == resp.http.Content-Encoding
expect resp.http.Content-Encoding == <undef>
expect resp.bodylen == 909
txreq -url "/2" -hdr "Accept-Encoding: gzip"
......
......@@ -24,6 +24,6 @@ client c1 {
txreq -url /foobar
rxresp
expect resp.http.content-encoding == "resp.http.content-encoding"
expect resp.http.content-encoding == <undef>
expect resp.bodylen == 43
} -run
......@@ -175,7 +175,7 @@ http_find_header(char * const *hh, const char *hdr)
* Expect
*/
static char *
static const char *
cmd_var_resolve(struct http *hp, char *spec)
{
char **hh, *hdr;
......@@ -207,16 +207,16 @@ cmd_var_resolve(struct http *hp, char *spec)
hdr = http_find_header(hh, hdr);
if (hdr != NULL)
return (hdr);
return (spec);
return ("<undef>");
}
static void
cmd_http_expect(CMD_ARGS)
{
struct http *hp;
char *lhs;
const char *lhs;
char *cmp;
char *rhs;
const char *rhs;
(void)cmd;
(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