Update redbean to include params in slash redirect (#604)

This commit is contained in:
Paul Kulchenko 2022-09-08 19:14:54 -07:00 committed by GitHub
parent 9f963dc597
commit 5140897c27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3047,14 +3047,25 @@ static char *ServeStatusz(void) {
} }
static char *RedirectSlash(void) { static char *RedirectSlash(void) {
size_t n; size_t n, i;
char *p, *e; char *p, *e;
LockInc(&shared->c.redirects); LockInc(&shared->c.redirects);
p = SetStatus(307, "Temporary Redirect"); p = SetStatus(307, "Temporary Redirect");
p = stpcpy(p, "Location: "); p = stpcpy(p, "Location: ");
e = EscapePath(url.path.p, url.path.n, &n); e = EscapePath(url.path.p, url.path.n, &n);
p = mempcpy(p, e, 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); free(e);
return p; return p;
} }