mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Cleanup: Set Connection:-Header via client->reuse
This commit is contained in:
parent
68248d15b1
commit
dbbd22f792
16
src/client.c
16
src/client.c
@ -201,6 +201,8 @@ void client_send_error(client_t *client, int status, int plain, const char *mess
|
||||
return;
|
||||
}
|
||||
|
||||
client->reuse = ICECAST_REUSE_KEEPALIVE;
|
||||
|
||||
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
|
||||
0, status, NULL,
|
||||
plain ? "text/plain" : "text/html", "utf-8",
|
||||
@ -223,15 +225,13 @@ void client_send_error(client_t *client, int status, int plain, const char *mess
|
||||
data->len = strlen(data->data);
|
||||
|
||||
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
|
||||
"Content-Length: %llu\r\nConnection: Keep-Alive\r\n\r\n",
|
||||
"Content-Length: %llu\r\n\r\n",
|
||||
(long long unsigned int)data->len);
|
||||
|
||||
client->respcode = status;
|
||||
client->refbuf->len = strlen (client->refbuf->data);
|
||||
client->refbuf->next = data;
|
||||
|
||||
client->reuse = ICECAST_REUSE_KEEPALIVE;
|
||||
|
||||
fserve_add_client (client, NULL);
|
||||
}
|
||||
|
||||
@ -253,19 +253,19 @@ void client_send_101(client_t *client, reuse_t reuse)
|
||||
return;
|
||||
}
|
||||
|
||||
client->reuse = reuse;
|
||||
|
||||
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
|
||||
0, 101, NULL,
|
||||
"text/plain", "utf-8",
|
||||
NULL, NULL, client);
|
||||
|
||||
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
|
||||
"Content-Length: 0\r\nUpgrade: TLS/1.0, HTTP/1.0\r\nConnection: Upgrade\r\n\r\n");
|
||||
"Content-Length: 0\r\nUpgrade: TLS/1.0, HTTP/1.0\r\n\r\n");
|
||||
|
||||
client->respcode = 101;
|
||||
client->refbuf->len = strlen(client->refbuf->data);
|
||||
|
||||
client->reuse = reuse;
|
||||
|
||||
fserve_add_client(client, NULL);
|
||||
}
|
||||
|
||||
@ -281,13 +281,15 @@ void client_send_426(client_t *client, reuse_t reuse)
|
||||
return;
|
||||
}
|
||||
|
||||
client->reuse = reuse;
|
||||
|
||||
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
|
||||
0, 426, NULL,
|
||||
"text/plain", "utf-8",
|
||||
NULL, NULL, client);
|
||||
|
||||
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
|
||||
"Content-Length: 0\r\nUpgrade: TLS/1.0, HTTP/1.0\r\nConnection: Upgrade\r\n\r\n");
|
||||
"Content-Length: 0\r\nUpgrade: TLS/1.0, HTTP/1.0\r\n\r\n");
|
||||
|
||||
client->respcode = 426;
|
||||
client->refbuf->len = strlen(client->refbuf->data);
|
||||
|
12
src/util.c
12
src/util.c
@ -632,10 +632,19 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
|
||||
char contenttype_buffer[80];
|
||||
ssize_t ret;
|
||||
char * extra_headers;
|
||||
const char *connection_header = "Close";
|
||||
|
||||
if (!out)
|
||||
return -1;
|
||||
|
||||
if (client) {
|
||||
switch (client->reuse) {
|
||||
case ICECAST_REUSE_CLOSE: connection_header = "Close"; break;
|
||||
case ICECAST_REUSE_KEEPALIVE: connection_header = "Keep-Alive"; break;
|
||||
case ICECAST_REUSE_UPGRADETLS: connection_header = "Upgrade"; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset == -1)
|
||||
offset = strlen (out);
|
||||
|
||||
@ -698,9 +707,10 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
|
||||
|
||||
config = config_get_config();
|
||||
extra_headers = _build_headers(status, config, source);
|
||||
ret = snprintf (out, len, "%sServer: %s\r\nAccept-Encoding: identity\r\nAllow: %s\r\n%s%s%s%s%s%s%s",
|
||||
ret = snprintf (out, len, "%sServer: %s\r\nConnection: %s\r\nAccept-Encoding: identity\r\nAllow: %s\r\n%s%s%s%s%s%s%s",
|
||||
status_buffer,
|
||||
config->server_id,
|
||||
connection_header,
|
||||
(client->admin_command == ADMIN_COMMAND_ERROR ?
|
||||
"GET, SOURCE" : "GET"),
|
||||
currenttime_buffer,
|
||||
|
Loading…
Reference in New Issue
Block a user