mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Fix: Corrected reported Allow:-header (mostly for 204-responses)
This commit is contained in:
parent
0bdad13fd2
commit
a192f696c3
10
src/client.c
10
src/client.c
@ -43,6 +43,7 @@
|
||||
#include "reportxml.h"
|
||||
#include "refobject.h"
|
||||
#include "xslt.h"
|
||||
#include "source.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "auth.h"
|
||||
@ -385,6 +386,7 @@ void client_send_101(client_t *client, reuse_t reuse)
|
||||
|
||||
void client_send_204(client_t *client)
|
||||
{
|
||||
source_t *source;
|
||||
ssize_t ret;
|
||||
|
||||
if (!client)
|
||||
@ -392,10 +394,16 @@ void client_send_204(client_t *client)
|
||||
|
||||
client->reuse = ICECAST_REUSE_KEEPALIVE;
|
||||
|
||||
/* We get a source_t* here as this is likely a reply to OPTIONS and we want
|
||||
* to have as much infos as possible in that case.
|
||||
*/
|
||||
avl_tree_rlock(global.source_tree);
|
||||
source = source_find_mount_raw(client->uri);
|
||||
ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
|
||||
0, 204, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL, client);
|
||||
NULL, source, client);
|
||||
avl_tree_unlock(global.source_tree);
|
||||
|
||||
snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
|
||||
"Content-Length: 0\r\n\r\n");
|
||||
|
16
src/util.c
16
src/util.c
@ -680,6 +680,7 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
|
||||
char * extra_headers;
|
||||
const char *connection_header = "Close";
|
||||
const char *upgrade_header = "";
|
||||
const char *allow_header;
|
||||
|
||||
if (!out)
|
||||
return -1;
|
||||
@ -771,14 +772,25 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
|
||||
else
|
||||
currenttime_buffer[0] = '\0';
|
||||
|
||||
if (client) {
|
||||
if (client->admin_command != ADMIN_COMMAND_ERROR) {
|
||||
allow_header = "GET, POST, OPTIONS";
|
||||
} else if (source) {
|
||||
allow_header = "GET, DELETE, OPTIONS";
|
||||
} else {
|
||||
allow_header = "GET, PUT, OPTIONS, SOURCE";
|
||||
}
|
||||
} else {
|
||||
allow_header = "GET, OPTIONS";
|
||||
}
|
||||
|
||||
config = config_get_config();
|
||||
extra_headers = _build_headers(status, config, source);
|
||||
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%s",
|
||||
status_buffer,
|
||||
config->server_id,
|
||||
connection_header,
|
||||
(client && client->admin_command == ADMIN_COMMAND_ERROR ?
|
||||
"GET, SOURCE, OPTIONS" : "GET, OPTIONS"),
|
||||
allow_header,
|
||||
upgrade_header,
|
||||
currenttime_buffer,
|
||||
contenttype_buffer,
|
||||
|
Loading…
Reference in New Issue
Block a user