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

Feature: Allow POST for admin requests

This commit is contained in:
Philipp Schafft 2018-06-18 21:40:47 +00:00
parent 44ebc3cf22
commit a466900ae1
3 changed files with 30 additions and 5 deletions

View File

@ -52,7 +52,7 @@
/* Helper macros */
#define COMMAND_REQUIRE(client,name,var) \
do { \
(var) = httpp_get_query_param((client)->parser, (name)); \
(var) = httpp_get_param((client)->parser, (name)); \
if((var) == NULL) { \
client_send_error_by_id(client, ICECAST_ERROR_ADMIN_MISSING_PARAMETER); \
return; \
@ -60,7 +60,7 @@
} while(0);
#define COMMAND_OPTIONAL(client,name,var) \
(var) = httpp_get_query_param((client)->parser, (name))
(var) = httpp_get_param((client)->parser, (name))
/* special commands */
#define COMMAND_ERROR ADMIN_COMMAND_ERROR
@ -502,7 +502,7 @@ void admin_handle_request(client_t *client, const char *uri)
}
}
mount = httpp_get_query_param(client->parser, "mount");
COMMAND_OPTIONAL(client, "mount", mount);
/* Find mountpoint source */
if(mount != NULL) {
@ -543,6 +543,7 @@ void admin_handle_request(client_t *client, const char *uri)
switch (client->parser->req_type) {
case httpp_req_get:
case httpp_req_post:
handler->function(client, source, format);
break;
case httpp_req_options:

@ -1 +1 @@
Subproject commit fca416b126cb842034ac3468362c044895975b5a
Subproject commit 9bfb3a34fc41cc8e0075328d7d6527bd84eb40ba

View File

@ -82,6 +82,8 @@ typedef struct client_queue_tag {
int stream_offset;
int shoutcast;
char *shoutcast_mount;
char *bodybuffer;
size_t bodybufferlen;
int tried_body;
struct client_queue_tag *next;
} client_queue_t;
@ -634,7 +636,28 @@ static void process_request_body_queue (void)
ICECAST_LOG_DEBUG("Got client %p in body queue.", client);
res = client_body_skip(client);
if (client->parser->req_type == httpp_req_post) {
if (node->bodybuffer == NULL && client->request_body_read == 0) {
if (client->request_body_length < 0) {
node->bodybufferlen = body_size_limit;
node->bodybuffer = malloc(node->bodybufferlen);
} else if (client->request_body_length <= (ssize_t)body_size_limit) {
node->bodybufferlen = client->request_body_length;
node->bodybuffer = malloc(node->bodybufferlen);
}
}
}
if (node->bodybuffer) {
res = client_body_slurp(client, node->bodybuffer, &(node->bodybufferlen));
if (res == CLIENT_SLURP_SUCCESS) {
httpp_parse_postdata(client->parser, node->bodybuffer, node->bodybufferlen);
free(node->bodybuffer);
node->bodybuffer = NULL;
}
} else {
res = client_body_skip(client);
}
if (res != CLIENT_SLURP_NEEDS_MORE_DATA || client->con->con_time <= timeout || client->request_body_read >= body_size_limit) {
ICECAST_LOG_DEBUG("Putting client %p back in connection queue.", client);
@ -1612,6 +1635,7 @@ static void _handle_connection(void)
if (node->shoutcast_mount && strcmp (rawuri, "/admin.cgi") == 0)
httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
free (node->bodybuffer);
free (node->shoutcast_mount);
free (node);