mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05:00
Feature: Allow POST for admin requests
This commit is contained in:
parent
44ebc3cf22
commit
a466900ae1
@ -52,7 +52,7 @@
|
|||||||
/* Helper macros */
|
/* Helper macros */
|
||||||
#define COMMAND_REQUIRE(client,name,var) \
|
#define COMMAND_REQUIRE(client,name,var) \
|
||||||
do { \
|
do { \
|
||||||
(var) = httpp_get_query_param((client)->parser, (name)); \
|
(var) = httpp_get_param((client)->parser, (name)); \
|
||||||
if((var) == NULL) { \
|
if((var) == NULL) { \
|
||||||
client_send_error_by_id(client, ICECAST_ERROR_ADMIN_MISSING_PARAMETER); \
|
client_send_error_by_id(client, ICECAST_ERROR_ADMIN_MISSING_PARAMETER); \
|
||||||
return; \
|
return; \
|
||||||
@ -60,7 +60,7 @@
|
|||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
#define COMMAND_OPTIONAL(client,name,var) \
|
#define COMMAND_OPTIONAL(client,name,var) \
|
||||||
(var) = httpp_get_query_param((client)->parser, (name))
|
(var) = httpp_get_param((client)->parser, (name))
|
||||||
|
|
||||||
/* special commands */
|
/* special commands */
|
||||||
#define COMMAND_ERROR ADMIN_COMMAND_ERROR
|
#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 */
|
/* Find mountpoint source */
|
||||||
if(mount != NULL) {
|
if(mount != NULL) {
|
||||||
@ -543,6 +543,7 @@ void admin_handle_request(client_t *client, const char *uri)
|
|||||||
|
|
||||||
switch (client->parser->req_type) {
|
switch (client->parser->req_type) {
|
||||||
case httpp_req_get:
|
case httpp_req_get:
|
||||||
|
case httpp_req_post:
|
||||||
handler->function(client, source, format);
|
handler->function(client, source, format);
|
||||||
break;
|
break;
|
||||||
case httpp_req_options:
|
case httpp_req_options:
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit fca416b126cb842034ac3468362c044895975b5a
|
Subproject commit 9bfb3a34fc41cc8e0075328d7d6527bd84eb40ba
|
@ -82,6 +82,8 @@ typedef struct client_queue_tag {
|
|||||||
int stream_offset;
|
int stream_offset;
|
||||||
int shoutcast;
|
int shoutcast;
|
||||||
char *shoutcast_mount;
|
char *shoutcast_mount;
|
||||||
|
char *bodybuffer;
|
||||||
|
size_t bodybufferlen;
|
||||||
int tried_body;
|
int tried_body;
|
||||||
struct client_queue_tag *next;
|
struct client_queue_tag *next;
|
||||||
} client_queue_t;
|
} client_queue_t;
|
||||||
@ -634,7 +636,28 @@ static void process_request_body_queue (void)
|
|||||||
|
|
||||||
ICECAST_LOG_DEBUG("Got client %p in body queue.", client);
|
ICECAST_LOG_DEBUG("Got client %p in body queue.", 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);
|
res = client_body_skip(client);
|
||||||
|
}
|
||||||
|
|
||||||
if (res != CLIENT_SLURP_NEEDS_MORE_DATA || client->con->con_time <= timeout || client->request_body_read >= body_size_limit) {
|
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);
|
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)
|
if (node->shoutcast_mount && strcmp (rawuri, "/admin.cgi") == 0)
|
||||||
httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
|
httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
|
||||||
|
|
||||||
|
free (node->bodybuffer);
|
||||||
free (node->shoutcast_mount);
|
free (node->shoutcast_mount);
|
||||||
free (node);
|
free (node);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user