/* Add listener to the pending lists of either the source or fserve thread. This can be run * from the connection or auth thread context. return -1 to indicate that client has been * terminated, 0 for receiving content. */ static int add_authenticated_listener (const char *mount, mount_proxy *mountinfo, client_t *client) { int ret = 0; if (client->parser->req_type != httpp_req_head) client->flags |= CLIENT_AUTHENTICATED; /* some win32 setups do not do TCP win scaling well, so allow an override */ if (mountinfo && mountinfo->so_sndbuf > 0) sock_set_send_buffer (client->connection.sock, mountinfo->so_sndbuf); /* check whether we are processing a streamlist request for slaves */ if (strcmp (mount, "/admin/streams") == 0) { client->flags |= CLIENT_IS_SLAVE; if (client->parser->req_type == httpp_req_stats) { stats_add_listener (client, STATS_SLAVE|STATS_GENERAL); return 0; } mount = httpp_get_query_param (client->parser, "mount"); if (mount == NULL) { command_list_mounts (client, TEXT); return 0; } mountinfo = config_find_mount (config_get_config_unlocked(), mount); } /* Here we are parsing the URI request to see if the extension is .xsl, if * so, then process this request as an XSLT request */ if (util_check_valid_extension (mount) == XSLT_CONTENT) { /* If the file exists, then transform it, otherwise, write a 404 */ DEBUG0("Stats request, sending XSL transformed stats"); return stats_transform_xslt (client, mount); } ret = source_add_listener (mount, mountinfo, client); if (ret == -2) { if (mountinfo && mountinfo->file_seekable == 0) { DEBUG1 ("disable seek on file matching %s", mountinfo->mountname); httpp_deletevar (client->parser, "range"); client->flags |= CLIENT_NO_CONTENT_LENGTH; } ret = fserve_client_create (client, mount); } return ret; }
static void admin_handle_general_request(client_t *client, int command) { switch(command) { case COMMAND_RAW_STATS: command_stats(client, NULL, RAW); break; case COMMAND_RAW_LIST_MOUNTS: command_list_mounts(client, RAW); break; case COMMAND_RAW_LISTSTREAM: command_list_mounts(client, RAW); break; case COMMAND_PLAINTEXT_LISTSTREAM: command_list_mounts(client, PLAINTEXT); break; case COMMAND_TRANSFORMED_STATS: command_stats(client, NULL, TRANSFORMED); break; case COMMAND_TRANSFORMED_LIST_MOUNTS: command_list_mounts(client, TRANSFORMED); break; case COMMAND_TRANSFORMED_LISTSTREAM: command_list_mounts(client, TRANSFORMED); break; case COMMAND_TRANSFORMED_MOVE_CLIENTS: command_list_mounts(client, TRANSFORMED); break; default: WARN0("General admin request not recognised"); client_send_400(client, "Unknown admin request"); return; } }