1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Fix: Corrected reported Allow:-header (mostly for 204-responses)

This commit is contained in:
Philipp Schafft 2018-10-26 08:05:45 +00:00
parent 0bdad13fd2
commit a192f696c3
2 changed files with 23 additions and 3 deletions

View File

@ -43,6 +43,7 @@
#include "reportxml.h" #include "reportxml.h"
#include "refobject.h" #include "refobject.h"
#include "xslt.h" #include "xslt.h"
#include "source.h"
#include "client.h" #include "client.h"
#include "auth.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) void client_send_204(client_t *client)
{ {
source_t *source;
ssize_t ret; ssize_t ret;
if (!client) if (!client)
@ -392,10 +394,16 @@ void client_send_204(client_t *client)
client->reuse = ICECAST_REUSE_KEEPALIVE; 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, ret = util_http_build_header(client->refbuf->data, PER_CLIENT_REFBUF_SIZE, 0,
0, 204, NULL, 0, 204, NULL,
NULL, 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, snprintf(client->refbuf->data + ret, PER_CLIENT_REFBUF_SIZE - ret,
"Content-Length: 0\r\n\r\n"); "Content-Length: 0\r\n\r\n");

View File

@ -680,6 +680,7 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
char * extra_headers; char * extra_headers;
const char *connection_header = "Close"; const char *connection_header = "Close";
const char *upgrade_header = ""; const char *upgrade_header = "";
const char *allow_header;
if (!out) if (!out)
return -1; return -1;
@ -771,14 +772,25 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
else else
currenttime_buffer[0] = '\0'; 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(); config = config_get_config();
extra_headers = _build_headers(status, config, source); 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", 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, status_buffer,
config->server_id, config->server_id,
connection_header, connection_header,
(client && client->admin_command == ADMIN_COMMAND_ERROR ? allow_header,
"GET, SOURCE, OPTIONS" : "GET, OPTIONS"),
upgrade_header, upgrade_header,
currenttime_buffer, currenttime_buffer,
contenttype_buffer, contenttype_buffer,