Commit 2bbb032b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Split absolute URIs into URL and Host: as per RFC2616 5.2

Fixes	#1255
parent 054fd6a6
......@@ -389,12 +389,15 @@ htc_proto_ver(struct http *hp)
/*--------------------------------------------------------------------*/
#include <stdio.h>
uint16_t
HTTP1_DissectRequest(struct req *req)
{
struct http_conn *htc;
struct http *hp;
uint16_t retval;
char *b, *e;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
htc = req->htc;
......@@ -408,8 +411,22 @@ HTTP1_DissectRequest(struct req *req)
return (retval);
}
htc_proto_ver(hp);
/* RFC2616, section 5.2, point 1 */
if (!strncasecmp(hp->hd[HTTP_HDR_URL].b, "http://", 7)) {
b = e = hp->hd[HTTP_HDR_URL].b + 7;
while (*e != '/' && *e != '\0')
e++;
if (*e == '/') {
http_Unset(hp, H_Host);
http_PrintfHeader(hp, "Host: %.*s", (int)(e - b), b);
hp->hd[HTTP_HDR_URL].b = e;
}
}
return (retval);
}
/*--------------------------------------------------------------------*/
uint16_t
......
varnishtest "Test RFC2616 5.2 compliance"
server s1 {
rxreq
txresp -hdr "Foo: 1"
} -start
varnish v1 -vcl+backend {
sub vcl_deliver {
set resp.http.rxhost = req.http.host;
}
} -start
client c1 {
txreq -url http://www.example.com/bar
rxresp
expect resp.http.rxhost == www.example.com
} -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