From: Willy Tarreau Date: Sat, 9 Jan 2010 23:24:22 +0000 (+0100) Subject: [MINOR] http: fix double slash prefix with server redirect X-Git-Tag: v1.4-dev7~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcb75c4a83246f4907cdd5ffac9cbd7b71732816;p=thirdparty%2Fhaproxy.git [MINOR] http: fix double slash prefix with server redirect When using server redirection, it is possible to specify a path consisting of only one slash. While this is discouraged (risk of loop) it may sometimes be useful combined with content switching. The prefixing of a '/' then causes two slashes to be returned in the response. So we now do as with the other redirects, don't prepend a slash if it's alone. --- diff --git a/src/proto_http.c b/src/proto_http.c index e06ebe68d2..75dd62a945 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -681,8 +681,11 @@ void perform_http_redirect(struct session *s, struct stream_interface *si) if (rdr.len + s->srv->rdr_len > rdr.size) return; - memcpy(rdr.str + rdr.len, s->srv->rdr_pfx, s->srv->rdr_len); - rdr.len += s->srv->rdr_len; + /* special prefix "/" means don't change URL */ + if (s->srv->rdr_len != 1 || *s->srv->rdr_pfx != '/') { + memcpy(rdr.str + rdr.len, s->srv->rdr_pfx, s->srv->rdr_len); + rdr.len += s->srv->rdr_len; + } /* 3: add the request URI */ txn = &s->txn;