Commit 0df154f3 authored by Philipp Schafft's avatar Philipp Schafft 🦁

remove client_send_[0-9]{3}() in favor of client_send_error(). Please test

svn path=/icecast/trunk/icecast/; revision=19344
parent 237eb4f7
...@@ -295,7 +295,7 @@ void admin_send_response (xmlDocPtr doc, client_t *client, ...@@ -295,7 +295,7 @@ void admin_send_response (xmlDocPtr doc, client_t *client,
NULL, NULL); NULL, NULL);
if (ret == -1) { if (ret == -1) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
xmlFree(buff); xmlFree(buff);
return; return;
} else if (buf_len < (len + ret + 64)) { } else if (buf_len < (len + ret + 64)) {
...@@ -312,13 +312,13 @@ void admin_send_response (xmlDocPtr doc, client_t *client, ...@@ -312,13 +312,13 @@ void admin_send_response (xmlDocPtr doc, client_t *client,
NULL, NULL); NULL, NULL);
if (ret == -1) { if (ret == -1) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
xmlFree(buff); xmlFree(buff);
return; return;
} }
} else { } else {
ICECAST_LOG_ERROR("Client buffer reallocation failed. Dropping client."); ICECAST_LOG_ERROR("Client buffer reallocation failed. Dropping client.");
client_send_500(client, "Buffer reallocation failed."); client_send_error(client, 500, 0, "Buffer reallocation failed.");
xmlFree(buff); xmlFree(buff);
return; return;
} }
...@@ -361,7 +361,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -361,7 +361,7 @@ void admin_handle_request(client_t *client, const char *uri)
if (!((strcmp(uri, "/admin.cgi") == 0) || if (!((strcmp(uri, "/admin.cgi") == 0) ||
(strncmp("/admin/", uri, 7) == 0))) { (strncmp("/admin/", uri, 7) == 0))) {
ICECAST_LOG_ERROR("Internal error: admin request isn't"); ICECAST_LOG_ERROR("Internal error: admin request isn't");
client_send_401(client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
return; return;
} }
...@@ -378,7 +378,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -378,7 +378,7 @@ void admin_handle_request(client_t *client, const char *uri)
if(command < 0) { if(command < 0) {
ICECAST_LOG_ERROR("Error parsing command string or unrecognised command: %s", ICECAST_LOG_ERROR("Error parsing command string or unrecognised command: %s",
command_string); command_string);
client_send_400(client, "Unrecognised command"); client_send_error(client, 400, 0, "Unrecognised command");
return; return;
} }
...@@ -391,7 +391,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -391,7 +391,7 @@ void admin_handle_request(client_t *client, const char *uri)
if (pass == NULL) if (pass == NULL)
{ {
client_send_400 (client, "missing pass parameter"); client_send_error(client, 400, 0, "missing pass parameter");
return; return;
} }
global_lock(); global_lock();
...@@ -430,7 +430,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -430,7 +430,7 @@ void admin_handle_request(client_t *client, const char *uri)
default: default:
ICECAST_LOG_INFO("Bad or missing password on mount modification admin " ICECAST_LOG_INFO("Bad or missing password on mount modification admin "
"request (command: %s)", command_string); "request (command: %s)", command_string);
client_send_401(client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
/* fall through */ /* fall through */
case 1: case 1:
return; return;
...@@ -445,7 +445,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -445,7 +445,7 @@ void admin_handle_request(client_t *client, const char *uri)
ICECAST_LOG_WARN("Admin command %s on non-existent source %s", ICECAST_LOG_WARN("Admin command %s on non-existent source %s",
command_string, mount); command_string, mount);
avl_tree_unlock(global.source_tree); avl_tree_unlock(global.source_tree);
client_send_400(client, "Source does not exist"); client_send_error(client, 400, 0, "Source does not exist");
} }
else else
{ {
...@@ -454,7 +454,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -454,7 +454,7 @@ void admin_handle_request(client_t *client, const char *uri)
avl_tree_unlock (global.source_tree); avl_tree_unlock (global.source_tree);
ICECAST_LOG_INFO("Received admin command %s on unavailable mount \"%s\"", ICECAST_LOG_INFO("Received admin command %s on unavailable mount \"%s\"",
command_string, mount); command_string, mount);
client_send_400 (client, "Source is not available"); client_send_error(client, 400, 0, "Source is not available");
return; return;
} }
if (command == COMMAND_SHOUTCAST_METADATA_UPDATE && if (command == COMMAND_SHOUTCAST_METADATA_UPDATE &&
...@@ -463,7 +463,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -463,7 +463,7 @@ void admin_handle_request(client_t *client, const char *uri)
avl_tree_unlock (global.source_tree); avl_tree_unlock (global.source_tree);
ICECAST_LOG_ERROR("illegal change of metadata on non-shoutcast " ICECAST_LOG_ERROR("illegal change of metadata on non-shoutcast "
"compatible stream"); "compatible stream");
client_send_400 (client, "illegal metadata call"); client_send_error(client, 400, 0, "illegal metadata call");
return; return;
} }
ICECAST_LOG_INFO("Received admin command %s on mount \"%s\"", ICECAST_LOG_INFO("Received admin command %s on mount \"%s\"",
...@@ -481,7 +481,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -481,7 +481,7 @@ void admin_handle_request(client_t *client, const char *uri)
if(!connection_check_relay_pass(client->parser)) { if(!connection_check_relay_pass(client->parser)) {
ICECAST_LOG_INFO("Bad or missing password on admin command " ICECAST_LOG_INFO("Bad or missing password on admin command "
"request (command: %s)", command_string); "request (command: %s)", command_string);
client_send_401(client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
return; return;
} }
} }
...@@ -489,7 +489,7 @@ void admin_handle_request(client_t *client, const char *uri) ...@@ -489,7 +489,7 @@ void admin_handle_request(client_t *client, const char *uri)
if(!connection_check_admin_pass(client->parser)) { if(!connection_check_admin_pass(client->parser)) {
ICECAST_LOG_INFO("Bad or missing password on admin command " ICECAST_LOG_INFO("Bad or missing password on admin command "
"request (command: %s)", command_string); "request (command: %s)", command_string);
client_send_401(client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
return; return;
} }
} }
...@@ -533,7 +533,7 @@ static void admin_handle_general_request(client_t *client, int command) ...@@ -533,7 +533,7 @@ static void admin_handle_general_request(client_t *client, int command)
break; break;
default: default:
ICECAST_LOG_WARN("General admin request not recognised"); ICECAST_LOG_WARN("General admin request not recognised");
client_send_400(client, "Unknown admin request"); client_send_error(client, 400, 0, "Unknown admin request");
return; return;
} }
} }
...@@ -601,7 +601,7 @@ static void admin_handle_mount_request(client_t *client, source_t *source, ...@@ -601,7 +601,7 @@ static void admin_handle_mount_request(client_t *client, source_t *source,
break; break;
default: default:
ICECAST_LOG_WARN("Mount request not recognised"); ICECAST_LOG_WARN("Mount request not recognised");
client_send_400(client, "Mount request unknown"); client_send_error(client, 400, 0, "Mount request unknown");
break; break;
} }
} }
...@@ -610,7 +610,7 @@ static void admin_handle_mount_request(client_t *client, source_t *source, ...@@ -610,7 +610,7 @@ static void admin_handle_mount_request(client_t *client, source_t *source,
do { \ do { \
(var) = httpp_get_query_param((client)->parser, (name)); \ (var) = httpp_get_query_param((client)->parser, (name)); \
if((var) == NULL) { \ if((var) == NULL) { \
client_send_400((client), "Missing parameter"); \ client_send_error((client), 400, 0, "Missing parameter"); \
return; \ return; \
} \ } \
} while(0); } while(0);
...@@ -628,7 +628,7 @@ static void html_success(client_t *client, char *message) ...@@ -628,7 +628,7 @@ static void html_success(client_t *client, char *message)
if (ret == -1 || ret >= PER_CLIENT_REFBUF_SIZE) { if (ret == -1 || ret >= PER_CLIENT_REFBUF_SIZE) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
return; return;
} }
...@@ -669,19 +669,19 @@ static void command_move_clients(client_t *client, source_t *source, ...@@ -669,19 +669,19 @@ static void command_move_clients(client_t *client, source_t *source,
if (dest == NULL) if (dest == NULL)
{ {
client_send_400 (client, "No such destination"); client_send_error(client, 400, 0, "No such destination");
return; return;
} }
if (strcmp (dest->mount, source->mount) == 0) if (strcmp (dest->mount, source->mount) == 0)
{ {
client_send_400 (client, "supplied mountpoints are identical"); client_send_error(client, 400, 0, "supplied mountpoints are identical");
return; return;
} }
if (dest->running == 0 && dest->on_demand == 0) if (dest->running == 0 && dest->on_demand == 0)
{ {
client_send_400 (client, "Destination not running"); client_send_error(client, 400, 0, "Destination not running");
return; return;
} }
...@@ -798,7 +798,7 @@ static void command_buildm3u(client_t *client, const char *mount) ...@@ -798,7 +798,7 @@ static void command_buildm3u(client_t *client, const char *mount)
if (ret == -1 || ret >= (PER_CLIENT_REFBUF_SIZE - 512)) { /* we want at least 512 Byte left for data */ if (ret == -1 || ret >= (PER_CLIENT_REFBUF_SIZE - 512)) { /* we want at least 512 Byte left for data */
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
return; return;
} }
...@@ -908,7 +908,7 @@ static void command_manageauth(client_t *client, source_t *source, ...@@ -908,7 +908,7 @@ static void command_manageauth(client_t *client, source_t *source,
} while (0); } while (0);
config_release_config (); config_release_config ();
client_send_400 (client, "missing parameter"); client_send_error(client, 400, 0, "missing parameter");
} }
static void command_kill_source(client_t *client, source_t *source, static void command_kill_source(client_t *client, source_t *source,
...@@ -1079,7 +1079,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source) ...@@ -1079,7 +1079,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source)
if (strcmp (action, "updinfo") != 0) if (strcmp (action, "updinfo") != 0)
{ {
client_send_400 (client, "No such action"); client_send_error(client, 400, 0, "No such action");
return; return;
} }
if (source->client && strcmp (client->con->ip, source->client->con->ip) != 0) if (source->client && strcmp (client->con->ip, source->client->con->ip) != 0)
...@@ -1097,7 +1097,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source) ...@@ -1097,7 +1097,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source)
} }
else else
{ {
client_send_400 (client, "mountpoint will not accept URL updates"); client_send_error(client, 400, 0, "mountpoint will not accept URL updates");
} }
} }
...@@ -1144,7 +1144,7 @@ static void command_list_mounts(client_t *client, int response) ...@@ -1144,7 +1144,7 @@ static void command_list_mounts(client_t *client, int response)
if (ret == -1 || ret >= PER_CLIENT_REFBUF_SIZE) { if (ret == -1 || ret >= PER_CLIENT_REFBUF_SIZE) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
return; return;
} }
......
...@@ -167,7 +167,7 @@ static void auth_client_free (auth_client *auth_user) ...@@ -167,7 +167,7 @@ static void auth_client_free (auth_client *auth_user)
if (client->respcode) if (client->respcode)
client_destroy (client); client_destroy (client);
else else
client_send_401 (client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
auth_user->client = NULL; auth_user->client = NULL;
} }
free (auth_user->mount); free (auth_user->mount);
...@@ -492,7 +492,7 @@ int auth_postprocess_listener (auth_client *auth_user) ...@@ -492,7 +492,7 @@ int auth_postprocess_listener (auth_client *auth_user)
config_release_config(); config_release_config();
if (ret < 0) if (ret < 0)
client_send_401 (auth_user->client); client_send_error(auth_user->client, 401, 1, "You need to authenticate\r\n");
auth_user->client = NULL; auth_user->client = NULL;
return ret; return ret;
...@@ -535,7 +535,7 @@ void auth_add_listener (const char *mount, client_t *client) ...@@ -535,7 +535,7 @@ void auth_add_listener (const char *mount, client_t *client)
if (mountinfo && mountinfo->no_mount) if (mountinfo && mountinfo->no_mount)
{ {
config_release_config (); config_release_config ();
client_send_403 (client, "mountpoint unavailable"); client_send_error(client, 403, 1, "mountpoint unavailable");
return; return;
} }
if (mountinfo && mountinfo->auth) if (mountinfo && mountinfo->auth)
...@@ -546,7 +546,7 @@ void auth_add_listener (const char *mount, client_t *client) ...@@ -546,7 +546,7 @@ void auth_add_listener (const char *mount, client_t *client)
{ {
config_release_config (); config_release_config ();
ICECAST_LOG_WARN("too many clients awaiting authentication"); ICECAST_LOG_WARN("too many clients awaiting authentication");
client_send_403 (client, "busy, please try again later"); client_send_error(client, 403, 1, "busy, please try again later");
return; return;
} }
auth_user = auth_client_setup (mount, client); auth_user = auth_client_setup (mount, client);
...@@ -560,7 +560,7 @@ void auth_add_listener (const char *mount, client_t *client) ...@@ -560,7 +560,7 @@ void auth_add_listener (const char *mount, client_t *client)
int ret = add_authenticated_listener (mount, mountinfo, client); int ret = add_authenticated_listener (mount, mountinfo, client);
config_release_config (); config_release_config ();
if (ret < 0) if (ret < 0)
client_send_403 (client, "max listeners reached"); client_send_error(client, 403, 1, "max listeners reached");
} }
} }
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
#undef CATMODULE #undef CATMODULE
#define CATMODULE "client" #define CATMODULE "client"
static inline void client_send_500(client_t *client, const char *message);
/* create a client_t with the provided connection and parser details. Return /* create a client_t with the provided connection and parser details. Return
* 0 on success, -1 if server limit has been reached. In either case a * 0 on success, -1 if server limit has been reached. In either case a
* client_t is returned just in case a message needs to be returned. Should * client_t is returned just in case a message needs to be returned. Should
...@@ -183,10 +185,15 @@ int client_read_bytes (client_t *client, void *buf, unsigned len) ...@@ -183,10 +185,15 @@ int client_read_bytes (client_t *client, void *buf, unsigned len)
return bytes; return bytes;
} }
static void client_send_error(client_t *client, int status, int plain, const char *message) void client_send_error(client_t *client, int status, int plain, const char *message)
{ {
ssize_t ret; ssize_t ret;
if (status == 500) {
client_send_500(client, message);
return;
}
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, status, NULL, 0, status, NULL,
plain ? "text/plain" : "text/html", "utf-8", plain ? "text/plain" : "text/html", "utf-8",
...@@ -214,28 +221,8 @@ void client_send_100(client_t *client) ...@@ -214,28 +221,8 @@ void client_send_100(client_t *client)
sock_write (client->con->sock, "HTTP/1.1 100 Continue\r\n\r\n"); sock_write (client->con->sock, "HTTP/1.1 100 Continue\r\n\r\n");
} }
void client_send_400(client_t *client, const char *message)
{
client_send_error(client, 400, 0, message);
}
void client_send_404(client_t *client, const char *message)
{
client_send_error(client, 404, 0, message);
}
void client_send_401(client_t *client)
{
client_send_error(client, 401, 1, "You need to authenticate\r\n");
}
void client_send_403(client_t *client, const char *message)
{
client_send_error(client, 403, 1, message);
}
/* this function is designed to work even if client is in bad state */ /* this function is designed to work even if client is in bad state */
void client_send_500(client_t *client, const char *message) { static inline void client_send_500(client_t *client, const char *message) {
const char header[] = "HTTP/1.0 500 Internal Server Error\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n" const char header[] = "HTTP/1.0 500 Internal Server Error\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n"
"500 - Internal Server Error\n---------------------------\n"; "500 - Internal Server Error\n---------------------------\n";
const size_t header_len = sizeof(header) - 1; const size_t header_len = sizeof(header) - 1;
......
...@@ -70,12 +70,8 @@ typedef struct _client_tag ...@@ -70,12 +70,8 @@ typedef struct _client_tag
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser); int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
void client_destroy(client_t *client); void client_destroy(client_t *client);
void client_send_error(client_t *client, int status, int plain, const char *message);
void client_send_100(client_t *client); void client_send_100(client_t *client);
void client_send_404(client_t *client, const char *message);
void client_send_401(client_t *client);
void client_send_403(client_t *client, const char *message);
void client_send_400(client_t *client, const char *message);
void client_send_500(client_t *client, const char *message);
int client_send_bytes (client_t *client, const void *buf, unsigned len); int client_send_bytes (client_t *client, const void *buf, unsigned len);
int client_read_bytes (client_t *client, void *buf, unsigned len); int client_read_bytes (client_t *client, void *buf, unsigned len);
void client_set_queue (client_t *client, refbuf_t *refbuf); void client_set_queue (client_t *client, refbuf_t *refbuf);
......
...@@ -732,7 +732,7 @@ void connection_accept_loop (void) ...@@ -732,7 +732,7 @@ void connection_accept_loop (void)
if (client_create (&client, con, NULL) < 0) if (client_create (&client, con, NULL) < 0)
{ {
global_unlock(); global_unlock();
client_send_403 (client, "Icecast connection limit reached"); client_send_error(client, 403, 1, "Icecast connection limit reached");
/* don't be too eager as this is an imposed hard limit */ /* don't be too eager as this is an imposed hard limit */
thread_sleep (400000); thread_sleep (400000);
continue; continue;
...@@ -823,7 +823,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -823,7 +823,7 @@ int connection_complete_source (source_t *source, int response)
config_release_config(); config_release_config();
global_unlock(); global_unlock();
if (response) { if (response) {
client_send_403 (source->client, "Content-type not supported"); client_send_error(source->client, 403, 1, "Content-type not supported");
source->client = NULL; source->client = NULL;
} }
ICECAST_LOG_WARN("Content-type \"%s\" not supported, dropping source", contenttype); ICECAST_LOG_WARN("Content-type \"%s\" not supported, dropping source", contenttype);
...@@ -833,7 +833,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -833,7 +833,7 @@ int connection_complete_source (source_t *source, int response)
config_release_config(); config_release_config();
global_unlock(); global_unlock();
if (response) { if (response) {
client_send_403 (source->client, "No Content-type given"); client_send_error(source->client, 403, 1, "No Content-type given");
source->client = NULL; source->client = NULL;
} }
ICECAST_LOG_ERROR("Content-type not given in PUT request, dropping source"); ICECAST_LOG_ERROR("Content-type not given in PUT request, dropping source");
...@@ -851,7 +851,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -851,7 +851,7 @@ int connection_complete_source (source_t *source, int response)
config_release_config(); config_release_config();
if (response) if (response)
{ {
client_send_403 (source->client, "internal format allocation problem"); client_send_error(source->client, 403, 1, "internal format allocation problem");
source->client = NULL; source->client = NULL;
} }
ICECAST_LOG_WARN("plugin format failed for \"%s\"", source->mount); ICECAST_LOG_WARN("plugin format failed for \"%s\"", source->mount);
...@@ -896,7 +896,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -896,7 +896,7 @@ int connection_complete_source (source_t *source, int response)
if (response) if (response)
{ {
client_send_403 (source->client, "too many sources connected"); client_send_error(source->client, 403, 1, "too many sources connected");
source->client = NULL; source->client = NULL;
} }
...@@ -1053,7 +1053,7 @@ static void _handle_source_request (client_t *client, const char *uri) ...@@ -1053,7 +1053,7 @@ static void _handle_source_request (client_t *client, const char *uri)
if (uri[0] != '/') if (uri[0] != '/')
{ {
ICECAST_LOG_WARN("source mountpoint not starting with /"); ICECAST_LOG_WARN("source mountpoint not starting with /");
client_send_401 (client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
return; return;
} }
switch (client_check_source_auth (client, uri)) switch (client_check_source_auth (client, uri))
...@@ -1067,7 +1067,7 @@ static void _handle_source_request (client_t *client, const char *uri) ...@@ -1067,7 +1067,7 @@ static void _handle_source_request (client_t *client, const char *uri)
default: /* failed */ default: /* failed */
ICECAST_LOG_INFO("Source (%s) attempted to login with invalid or missing password", uri); ICECAST_LOG_INFO("Source (%s) attempted to login with invalid or missing password", uri);
client_send_401(client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
break; break;
} }
} }
...@@ -1110,7 +1110,7 @@ void source_startup (client_t *client, const char *uri, int auth_style) ...@@ -1110,7 +1110,7 @@ void source_startup (client_t *client, const char *uri, int auth_style)
} }
else else
{ {
client_send_403 (client, "Mountpoint in use"); client_send_error(client, 403, 1, "Mountpoint in use");
ICECAST_LOG_WARN("Mountpoint %s in use", uri); ICECAST_LOG_WARN("Mountpoint %s in use", uri);
} }
} }
...@@ -1122,7 +1122,7 @@ static void _handle_stats_request (client_t *client, char *uri) ...@@ -1122,7 +1122,7 @@ static void _handle_stats_request (client_t *client, char *uri)
if (connection_check_admin_pass (client->parser) == 0) if (connection_check_admin_pass (client->parser) == 0)
{ {
client_send_401 (client); client_send_error(client, 401, 1, "You need to authenticate\r\n");
ICECAST_LOG_ERROR("Bad password for stats connection"); ICECAST_LOG_ERROR("Bad password for stats connection");
return; return;
} }
...@@ -1397,7 +1397,7 @@ static void _handle_connection(void) ...@@ -1397,7 +1397,7 @@ static void _handle_connection(void)
} }
else { else {
ICECAST_LOG_ERROR("Wrong request type from client"); ICECAST_LOG_ERROR("Wrong request type from client");
client_send_400 (client, "unknown request"); client_send_error(client, 400, 0, "unknown request");
} }
free(uri); free(uri);
......
...@@ -302,7 +302,7 @@ static int format_prepare_headers (source_t *source, client_t *client) ...@@ -302,7 +302,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
bytes = util_http_build_header(ptr, remaining, 0, 0, 200, NULL, source->format->contenttype, NULL, NULL, source); bytes = util_http_build_header(ptr, remaining, 0, 0, 200, NULL, source->format->contenttype, NULL, NULL, source);
if (bytes == -1) { if (bytes == -1) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
return -1; return -1;
} else if ((bytes + 1024) >= remaining) { /* we don't know yet how much to follow but want at least 1kB free space */ } else if ((bytes + 1024) >= remaining) { /* we don't know yet how much to follow but want at least 1kB free space */
void *new_ptr = realloc(ptr, bytes + 1024); void *new_ptr = realloc(ptr, bytes + 1024);
...@@ -313,12 +313,12 @@ static int format_prepare_headers (source_t *source, client_t *client) ...@@ -313,12 +313,12 @@ static int format_prepare_headers (source_t *source, client_t *client)
bytes = util_http_build_header(ptr, remaining, 0, 0, 200, NULL, source->format->contenttype, NULL, NULL, source); bytes = util_http_build_header(ptr, remaining, 0, 0, 200, NULL, source->format->contenttype, NULL, NULL, source);
if (bytes == -1 ) { if (bytes == -1 ) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_500(client, "Header generation failed."); client_send_error(client, 500, 0, "Header generation failed.");
return -1; return -1;
} }
} else { } else {
ICECAST_LOG_ERROR("Client buffer reallocation failed. Dropping client."); ICECAST_LOG_ERROR("Client buffer reallocation failed. Dropping client.");
client_send_500(client, "Buffer reallocation failed."); client_send_error(client, 500, 0, "Buffer reallocation failed.");
return -1; return -1;
} }
} }
......