summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2010-01-10 00:24:22 +0100
committerWilly Tarreau <w@1wt.eu>2010-01-28 23:16:36 +0100
commitcd2ae4f3427631488e32519ac67d9ee2a45657c3 (patch)
tree030f98dfcf1cde0f4cb38c04f5658345f4d1e98b /src
parent1df8a6a684a60aa42f0b01ad7cdcc414a7dfa6d3 (diff)
downloadhaproxy-cd2ae4f3427631488e32519ac67d9ee2a45657c3.tar.gz
[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. (cherry picked from commit dcb75c4a83246f4907cdd5ffac9cbd7b71732816)
Diffstat (limited to 'src')
-rw-r--r--src/proto_http.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/proto_http.c b/src/proto_http.c
index 421b6c069..e656a29f9 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -651,8 +651,11 @@ void perform_http_redirect(struct session *s, struct stream_interface *si)
if (rdr.len + s->srv->rdr_len > sizeof(trash))
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;