mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
Update redbean to include params in slash redirect (#604)
This commit is contained in:
parent
9f963dc597
commit
5140897c27
1 changed files with 13 additions and 2 deletions
|
@ -3047,14 +3047,25 @@ static char *ServeStatusz(void) {
|
|||
}
|
||||
|
||||
static char *RedirectSlash(void) {
|
||||
size_t n;
|
||||
size_t n, i;
|
||||
char *p, *e;
|
||||
LockInc(&shared->c.redirects);
|
||||
p = SetStatus(307, "Temporary Redirect");
|
||||
p = stpcpy(p, "Location: ");
|
||||
e = EscapePath(url.path.p, url.path.n, &n);
|
||||
p = mempcpy(p, e, n);
|
||||
p = stpcpy(p, "/\r\n");
|
||||
p = stpcpy(p, "/");
|
||||
|
||||
for (i = 0; i < url.params.n; ++i) {
|
||||
p = stpcpy(p, i == 0 ? "?" : "&");
|
||||
p = mempcpy(p, url.params.p[i].key.p, url.params.p[i].key.n);
|
||||
if (url.params.p[i].val.p) {
|
||||
p = stpcpy(p, "=");
|
||||
p = mempcpy(p, url.params.p[i].val.p, url.params.p[i].val.n);
|
||||
}
|
||||
}
|
||||
|
||||
p = stpcpy(p, "\r\n");
|
||||
free(e);
|
||||
return p;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue