Commit 4c59684e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Implement correct handling of the Expect: header.

Fixes #309



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3206 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9ec4a958
......@@ -889,6 +889,8 @@ static int
cnt_start(struct sess *sp)
{
int done;
char *p;
const char *r = "HTTP/1.1 100 Continue\r\n\r\n";
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->restarts);
......@@ -929,6 +931,21 @@ cnt_start(struct sess *sp)
/* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */
/*
* Handle Expect headers
*/
if (http_GetHdr(sp->http, H_Expect, &p)) {
if (strcmp(p, "100-continue")) {
sp->err_code = 417;
sp->step = STP_ERROR;
return (0);
}
/* XXX: Don't bother with write failures for now */
(void)write(sp->fd, r, strlen(r));
http_Unset(sp->http, H_Expect);
}
sp->step = STP_RECV;
return (0);
}
......
......@@ -49,10 +49,6 @@ sub vcl_recv {
/* Non-RFC2616 or CONNECT which is weird. */
pipe;
}
if (req.http.Expect) {
/* Expect is just too hard at present. */
pipe;
}
if (req.request != "GET" && req.request != "HEAD") {
/* We only deal with GET and HEAD by default */
pass;
......
# $Id$
test "Check Expect headers"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend { } -start
client c1 {
txreq -url "/" -req POST -hdr "Expect: 100-continue " -body "foo"
rxresp
expect resp.status == 100
rxresp
expect resp.status == 200
txreq -url "/" -req POST -hdr "Expect: 101-continue" -body "foo"
rxresp
expect resp.status == 417
} -run
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