Commit 5433df2c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

If we get a HTTP/1.1 response with no indicatation of length, assume EOF

encoding, rather than zero length.

This has implications for a number of testcases which were written
using the previous assumption.

Fixes: #733



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5075 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 1186896e
......@@ -446,7 +446,10 @@ FetchBody(struct sess *sp)
is_head = (strcasecmp(http_GetReq(sp->wrk->bereq), "head") == 0);
/* Determine if we have a body or not */
/*
* Determine if we have a body or not
* XXX: Missing: RFC2616 sec. 4.4 in re 1xx, 204 & 304 responses
*/
cls = 0;
mklen = 0;
if (is_head) {
......@@ -493,6 +496,7 @@ FetchBody(struct sess *sp)
* Assume zero length
* XXX: ???
*/
cls = fetch_eof(sp, sp->wrk->htc);
mklen = 1;
}
......
......@@ -4,7 +4,9 @@ test "Check HTTP/1.0 EOF transmission"
server s1 {
rxreq
txresp -hdr "Connection: close"
send "HTTP/1.1 200 Ok\n"
send "Connection: close\n"
send "\n"
send "Body line 1\n"
send "Body line 2\n"
send "Body line 3\n"
......
......@@ -8,7 +8,9 @@ server s1 {
rxreq
txresp -proto HTTP/1.0 -hdr "Connection: keep-alive"
rxreq
txresp -hdr "Transfer-encoding: foobar"
send "HTTP/1.1 200 Ok\n"
send "Transfer-encoding: foobar\n"
send "\n"
} -start
varnish v1 -vcl+backend {} -start
......
......@@ -18,7 +18,9 @@ test "ESI spanning storage bits"
server s1 {
rxreq
expect req.url == "/foo/bar"
txresp -hdr "Connection: close"
send "HTTP/1.1 200 Ok\n"
send "Connection: close\n"
send "\n"
send {
<html>filler
This is before the test
......
......@@ -5,7 +5,9 @@ test "Check <esi: detector"
server s1 {
rxreq
expect req.url == "/foo"
txresp -hdr "Connection: close"
send "HTTP/1.1 200 Ok\n"
send "Connection: close\n"
send "\n"
send { <a> <esi/> }
} -start
......
# $Id$
test "HTTP/1.1 Backend sends no length hint"
server s1 {
rxreq
send "HTTP/1.1 200 Ok\n"
send "\n"
send "12345"
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq
rxresp
expect resp.bodylen == 5
} -run
......@@ -507,7 +507,8 @@ cmd_http_txresp(CMD_ARGS)
const char *msg = "Ok";
int bodylen = 0;
char *b, *c;
char *body = NULL;
char *body = NULL, *nullbody;
(void)cmd;
(void)vl;
......@@ -518,6 +519,10 @@ cmd_http_txresp(CMD_ARGS)
vsb_clear(hp->vsb);
/* send a "Content-Length: 0" header unless something else happens */
REPLACE(body, "");
nullbody = body;
for(; *av != NULL; av++) {
if (!strcmp(*av, "-proto")) {
proto = av[1];
......@@ -544,8 +549,9 @@ cmd_http_txresp(CMD_ARGS)
}
for(; *av != NULL; av++) {
if (!strcmp(*av, "-body")) {
AZ(body);
assert(body == nullbody);
REPLACE(body, av[1]);
AN(body);
av++;
bodylen = strlen(body);
......@@ -560,7 +566,7 @@ cmd_http_txresp(CMD_ARGS)
}
}
} else if (!strcmp(*av, "-bodylen")) {
AZ(body);
assert(body == nullbody);
body = synth_body(av[1]);
bodylen = strlen(body);
av++;
......
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