Commit a94e8d47 authored by Guillaume Quintard's avatar Guillaume Quintard Committed by Lasse Karstensen

Add https_scheme feature bit

Allow to split https URI in the request line
parent dd758ea9
......@@ -344,7 +344,7 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
{
uint16_t retval;
const char *p;
const char *b, *e;
const char *b = NULL, *e;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
......@@ -363,8 +363,12 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
return (400);
/* RFC2616, section 5.2, point 1 */
if (!strncasecmp(hp->hd[HTTP_HDR_URL].b, "http://", 7)) {
if (!strncasecmp(hp->hd[HTTP_HDR_URL].b, "http://", 7))
b = e = hp->hd[HTTP_HDR_URL].b + 7;
else if (FEATURE(FEATURE_HTTPS_SCHEME) &&
!strncasecmp(hp->hd[HTTP_HDR_URL].b, "https://", 8))
b = e = hp->hd[HTTP_HDR_URL].b + 8;
if (b) {
while (*e != '/' && *e != '\0')
e++;
if (*e == '/') {
......
varnishtest "Test https_scheme parameter"
server s1 {
rxreq
expect req.url == /bar
txresp
rxreq
expect req.url == https://www.example.com/bar
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_deliver {
set resp.http.rxhost = req.http.host;
set resp.http.rxurl = req.url;
}
} -start
client c1 {
txreq -url http://www.example.com/bar
rxresp
expect resp.http.rxhost == www.example.com
expect resp.http.rxurl == /bar
txreq -url https://www.example.com/bar
rxresp
expect resp.http.rxhost == ""
expect resp.http.rxurl == https://www.example.com/bar
} -run
varnish v1 -cliok "param.set feature +https_scheme"
client c1 {
txreq -url http://www.example.com/bar
rxresp
expect resp.http.rxhost == www.example.com
expect resp.http.rxurl == /bar
txreq -url https://www.example.com/bar
rxresp
expect resp.http.rxhost == www.example.com
expect resp.http.rxurl == /bar
} -run
......@@ -59,4 +59,9 @@ FEATURE_BIT(ESI_REMOVE_BOM, esi_remove_bom,
"Remove UTF-8 BOM from front of object."
"Ignore and remove the UTF-8 BOM (0xeb 0xbb 0xbf) from front of object."
)
FEATURE_BIT(HTTPS_SCHEME, https_scheme,
"Also split https URIs",
"Extract host from full URI in the request line if the scheme is "
"https."
)
/*lint -restore */
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