mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
MEDIUM: http: implement redirect 307 and 308
I needed to emit a 307 and noticed it was not available so I did it, as well as 308.
This commit is contained in:
parent
4e8ec500e5
commit
3e8d1ae2d2
@ -92,6 +92,20 @@ const char *HTTP_303 =
|
|||||||
"Content-length: 0\r\n"
|
"Content-length: 0\r\n"
|
||||||
"Location: "; /* not terminated since it will be concatenated with the URL */
|
"Location: "; /* not terminated since it will be concatenated with the URL */
|
||||||
|
|
||||||
|
|
||||||
|
/* same as 302 except that the browser MUST retry with the same method */
|
||||||
|
const char *HTTP_307 =
|
||||||
|
"HTTP/1.1 307 Temporary Redirect\r\n"
|
||||||
|
"Cache-Control: no-cache\r\n"
|
||||||
|
"Content-length: 0\r\n"
|
||||||
|
"Location: "; /* not terminated since it will be concatenated with the URL */
|
||||||
|
|
||||||
|
/* same as 301 except that the browser MUST retry with the same method */
|
||||||
|
const char *HTTP_308 =
|
||||||
|
"HTTP/1.1 308 Permanent Redirect\r\n"
|
||||||
|
"Content-length: 0\r\n"
|
||||||
|
"Location: "; /* not terminated since it will be concatenated with the URL */
|
||||||
|
|
||||||
/* Warning: this one is an sprintf() fmt string, with <realm> as its only argument */
|
/* Warning: this one is an sprintf() fmt string, with <realm> as its only argument */
|
||||||
const char *HTTP_401_fmt =
|
const char *HTTP_401_fmt =
|
||||||
"HTTP/1.0 401 Unauthorized\r\n"
|
"HTTP/1.0 401 Unauthorized\r\n"
|
||||||
@ -3140,6 +3154,12 @@ static int http_apply_redirect_rule(struct redirect_rule *rule, struct session *
|
|||||||
|
|
||||||
/* build redirect message */
|
/* build redirect message */
|
||||||
switch(rule->code) {
|
switch(rule->code) {
|
||||||
|
case 308:
|
||||||
|
msg_fmt = HTTP_308;
|
||||||
|
break;
|
||||||
|
case 307:
|
||||||
|
msg_fmt = HTTP_307;
|
||||||
|
break;
|
||||||
case 303:
|
case 303:
|
||||||
msg_fmt = HTTP_303;
|
msg_fmt = HTTP_303;
|
||||||
break;
|
break;
|
||||||
@ -8228,9 +8248,9 @@ struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, st
|
|||||||
|
|
||||||
cur_arg++;
|
cur_arg++;
|
||||||
code = atol(args[cur_arg]);
|
code = atol(args[cur_arg]);
|
||||||
if (code < 301 || code > 303) {
|
if (code < 301 || code > 308 || (code > 303 && code < 307)) {
|
||||||
memprintf(errmsg,
|
memprintf(errmsg,
|
||||||
"'%s': unsupported HTTP code '%s' (must be a number between 301 and 303)",
|
"'%s': unsupported HTTP code '%s' (must be one of 301, 302, 303, 307 or 308)",
|
||||||
args[cur_arg - 1], args[cur_arg]);
|
args[cur_arg - 1], args[cur_arg]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user