Bugfix for redirection

This commit is contained in:
2020-12-19 13:17:30 +01:00
parent 4e079e094f
commit ba57509461
2 changed files with 11 additions and 4 deletions

View File

@ -136,12 +136,17 @@ int client_request_handler(sock *client, int req_num) {
ssize_t size = sizeof(buf0);
url_decode(req.uri, buf0, &size);
if (strcmp(uri.uri, buf0) != 0 || (strncmp(uri.uri, "/.well-known/", 13) != 0 && !client->enc)) {
int change_proto = strncmp(uri.uri, "/.well-known/", 13) != 0 && !client->enc;
if (strcmp(uri.uri, buf0) != 0 || change_proto) {
res.status = http_get_status(308);
size = sizeof(buf0);
encode_url(uri.uri, buf0, &size);
sprintf(buf1, "https://%s%s", host, buf0);
http_add_header_field(&res.hdr, "Location", buf1);
if (change_proto) {
sprintf(buf1, "https://%s%s", host, buf0);
http_add_header_field(&res.hdr, "Location", buf1);
} else {
http_add_header_field(&res.hdr, "Location", buf0);
}
goto respond;
}