Commit 0bdad13f authored by Philipp Schafft's avatar Philipp Schafft

Feature: Implemented DELETE on sources

parent ccca2460
......@@ -1101,7 +1101,7 @@ static void _parse_root(xmlDocPtr doc,
"legacy-global-source",
AUTH_TYPE_STATIC, "source",
source_password, NULL,
"source,put,get", 0, "*");
"source,put,get,delete", 0, "*");
}
} else {
ICECAST_LOG_ERROR("Can not find nor create default mount, but "
......@@ -1990,7 +1990,7 @@ static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,
if (admin_password && admin_username)
__append_old_style_auth(&old_style, "legacy-admin", AUTH_TYPE_STATIC,
admin_username, admin_password, NULL, "get,post,head,stats,options", 1, "*");
admin_username, admin_password, NULL, "get,post,head,stats,options,delete", 1, "*");
if (relay_password && relay_username)
__append_old_style_auth(&old_style, "legacy-relay", AUTH_TYPE_STATIC,
......
......@@ -1066,6 +1066,21 @@ static void _handle_get_request(client_t *client) {
}
}
static void _handle_delete_request(client_t *client) {
source_t *source;
avl_tree_wlock(global.source_tree);
source = source_find_mount_raw(client->uri);
if (source) {
source->running = 0;
avl_tree_unlock(global.source_tree);
client_send_204(client);
} else {
avl_tree_unlock(global.source_tree);
client_send_error_by_id(client, ICECAST_ERROR_CON_UNKNOWN_REQUEST);
}
}
static void _handle_shoutcast_compatible(client_queue_t *node)
{
char *http_compliant;
......@@ -1328,6 +1343,9 @@ static void _handle_authed_client(client_t *client, void *userdata, auth_result
case httpp_req_options:
_handle_get_request(client);
break;
case httpp_req_delete:
_handle_delete_request(client);
break;
default:
ICECAST_LOG_ERROR("Wrong request type from client");
client_send_error_by_id(client, ICECAST_ERROR_CON_UNKNOWN_REQUEST);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment