[httpd] Replace evhttp_send_error with the httpd_send_error wrapper

This commit is contained in:
ejurgensen 2016-10-18 22:45:22 +02:00
parent fe7373e442
commit c44f4310b7
6 changed files with 60 additions and 60 deletions

View File

@ -356,7 +356,7 @@ dmap_send_error(struct evhttp_request *req, const char *container, const char *e
{
DPRINTF(E_LOG, L_DMAP, "Could not allocate evbuffer for DMAP error\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
return;
}
@ -367,7 +367,7 @@ dmap_send_error(struct evhttp_request *req, const char *container, const char *e
{
DPRINTF(E_LOG, L_DMAP, "Could not expand evbuffer for DMAP error\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
evbuffer_free(evbuf);
return;

View File

@ -860,7 +860,7 @@ redirect_to_index(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Redirection URL exceeds buffer length\n");
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
return;
}
@ -907,7 +907,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Remote web interface request denied; no password set\n");
evhttp_send_error(req, 403, "Forbidden");
httpd_send_error(req, 403, "Forbidden");
return;
}
}
@ -917,7 +917,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Request exceeds PATH_MAX: %s\n", uri);
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
return;
}
@ -927,7 +927,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Could not lstat() %s: %s\n", path, strerror(errno));
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
return;
}
@ -945,7 +945,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Could not dereference %s: %s\n", path, strerror(errno));
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
return;
}
@ -954,7 +954,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Dereferenced path exceeds PATH_MAX: %s\n", path);
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
free(deref);
return;
@ -968,7 +968,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Could not stat() %s: %s\n", path, strerror(errno));
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
return;
}
@ -983,7 +983,7 @@ serve_file(struct evhttp_request *req, char *uri)
if (path_is_legal(path) != 0)
{
evhttp_send_error(req, 403, "Forbidden");
httpd_send_error(req, 403, "Forbidden");
return;
}
@ -993,7 +993,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Could not create evbuffer\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal error");
return;
}
@ -1002,7 +1002,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Could not open %s: %s\n", path, strerror(errno));
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
return;
}
@ -1015,7 +1015,7 @@ serve_file(struct evhttp_request *req, char *uri)
{
DPRINTF(E_LOG, L_HTTPD, "Could not read file into evbuffer\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal error");
return;
}
@ -1299,21 +1299,21 @@ httpd_basic_auth(struct evhttp_request *req, char *user, char *passwd, char *rea
header = (char *)malloc(len);
if (!header)
{
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
return -1;
}
ret = snprintf(header, len, "Basic realm=\"%s\"", realm);
if ((ret < 0) || (ret >= len))
{
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
return -1;
}
evbuf = evbuffer_new();
if (!evbuf)
{
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
return -1;
}

View File

@ -282,7 +282,7 @@ daap_session_find(struct evhttp_request *req, struct evkeyvalq *query, struct ev
return s;
invalid:
evhttp_send_error(req, 403, "Forbidden");
httpd_send_error(req, 403, "Forbidden");
return NULL;
}
@ -954,7 +954,7 @@ daap_reply_login(struct evhttp_request *req, struct evbuffer *evbuf, char **uri,
{
DPRINTF(E_LOG, L_DAAP, "Login attempt with U-A: Remote and no pairing-guid\n");
evhttp_send_error(req, 403, "Forbidden");
httpd_send_error(req, 403, "Forbidden");
return -1;
}
@ -967,7 +967,7 @@ daap_reply_login(struct evhttp_request *req, struct evbuffer *evbuf, char **uri,
DPRINTF(E_LOG, L_DAAP, "Login attempt with invalid pairing-guid\n");
free_pi(&pi, 1);
evhttp_send_error(req, 403, "Forbidden");
httpd_send_error(req, 403, "Forbidden");
return -1;
}
@ -2378,7 +2378,7 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
ret = safe_atoi32(uri[3], &id);
if (ret < 0)
{
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return -1;
}
@ -2390,7 +2390,7 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
{
DPRINTF(E_LOG, L_DAAP, "Could not convert mw parameter to integer\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return -1;
}
@ -2400,7 +2400,7 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
{
DPRINTF(E_LOG, L_DAAP, "Could not convert mh parameter to integer\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return -1;
}
}
@ -2458,7 +2458,7 @@ daap_stream(struct evhttp_request *req, struct evbuffer *evbuf, char **uri, stru
ret = safe_atoi32(uri[3], &id);
if (ret < 0)
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
else
httpd_stream_file(req, id);
@ -2710,7 +2710,7 @@ daap_request(struct evhttp_request *req)
full_uri = httpd_fixup_uri(req);
if (!full_uri)
{
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2718,7 +2718,7 @@ daap_request(struct evhttp_request *req)
if (!ptr)
{
free(full_uri);
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2729,7 +2729,7 @@ daap_request(struct evhttp_request *req)
if (!uri)
{
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2740,7 +2740,7 @@ daap_request(struct evhttp_request *req)
if (!uri)
{
free(full_uri);
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2761,7 +2761,7 @@ daap_request(struct evhttp_request *req)
{
DPRINTF(E_LOG, L_DAAP, "Unrecognized DAAP request\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
free(uri);
free(full_uri);
@ -2819,7 +2819,7 @@ daap_request(struct evhttp_request *req)
{
DPRINTF(E_LOG, L_DAAP, "DAAP URI has too many/few components (%d)\n", (uri_parts[0]) ? i : 0);
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
free(uri);
free(full_uri);
@ -2841,7 +2841,7 @@ daap_request(struct evhttp_request *req)
{
DPRINTF(E_LOG, L_DAAP, "Could not allocate evbuffer for DAAP reply\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
free(uri);
free(full_uri);

View File

@ -1286,7 +1286,7 @@ dacp_reply_playspec(struct evhttp_request *req, struct evbuffer *evbuf, char **u
return;
out_fail:
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
}
static void
@ -1328,7 +1328,7 @@ dacp_reply_playpause(struct evhttp_request *req, struct evbuffer *evbuf, char **
{
DPRINTF(E_LOG, L_DACP, "Player returned an error for start after pause\n");
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
return;
}
}
@ -1352,7 +1352,7 @@ dacp_reply_nextitem(struct evhttp_request *req, struct evbuffer *evbuf, char **u
{
DPRINTF(E_LOG, L_DACP, "Player returned an error for nextitem\n");
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
return;
}
@ -1361,7 +1361,7 @@ dacp_reply_nextitem(struct evhttp_request *req, struct evbuffer *evbuf, char **u
{
DPRINTF(E_LOG, L_DACP, "Player returned an error for start after nextitem\n");
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
return;
}
@ -1384,7 +1384,7 @@ dacp_reply_previtem(struct evhttp_request *req, struct evbuffer *evbuf, char **u
{
DPRINTF(E_LOG, L_DACP, "Player returned an error for previtem\n");
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
return;
}
@ -1393,7 +1393,7 @@ dacp_reply_previtem(struct evhttp_request *req, struct evbuffer *evbuf, char **u
{
DPRINTF(E_LOG, L_DACP, "Player returned an error for start after previtem\n");
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
return;
}
@ -2023,7 +2023,7 @@ dacp_reply_playstatusupdate(struct evhttp_request *req, struct evbuffer *evbuf,
{
ret = make_playstatusupdate(evbuf);
if (ret < 0)
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
else
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
@ -2076,7 +2076,7 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf,
{
DPRINTF(E_LOG, L_DACP, "Request for artwork without mw parameter\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2085,7 +2085,7 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf,
{
DPRINTF(E_LOG, L_DACP, "Could not convert mw parameter to integer\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2094,7 +2094,7 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf,
{
DPRINTF(E_LOG, L_DACP, "Request for artwork without mh parameter\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2103,7 +2103,7 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf,
{
DPRINTF(E_LOG, L_DACP, "Could not convert mh parameter to integer\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2141,7 +2141,7 @@ dacp_reply_nowplayingartwork(struct evhttp_request *req, struct evbuffer *evbuf,
return;
no_artwork:
evhttp_send_error(req, HTTP_NOTFOUND, "Not Found");
httpd_send_error(req, HTTP_NOTFOUND, "Not Found");
}
static void
@ -2376,7 +2376,7 @@ dacp_reply_setspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
{
DPRINTF(E_LOG, L_DACP, "Missing speaker-id parameter in DACP setspeakers request\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2396,7 +2396,7 @@ dacp_reply_setspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
{
DPRINTF(E_LOG, L_DACP, "Out of memory for speaker ids\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
return;
}
@ -2436,9 +2436,9 @@ dacp_reply_setspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
/* Password problem */
if (ret == -2)
evhttp_send_error(req, 902, "");
httpd_send_error(req, 902, "");
else
evhttp_send_error(req, 500, "Internal Server Error");
httpd_send_error(req, 500, "Internal Server Error");
return;
}
@ -2547,7 +2547,7 @@ dacp_request(struct evhttp_request *req)
full_uri = httpd_fixup_uri(req);
if (!full_uri)
{
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2559,7 +2559,7 @@ dacp_request(struct evhttp_request *req)
if (!uri)
{
free(full_uri);
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
@ -2587,7 +2587,7 @@ dacp_request(struct evhttp_request *req)
{
DPRINTF(E_LOG, L_DACP, "Unrecognized DACP request\n");
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
free(uri);
free(full_uri);
@ -2608,7 +2608,7 @@ dacp_request(struct evhttp_request *req)
{
DPRINTF(E_LOG, L_DACP, "DACP URI has too many/few components (%d)\n", (uri_parts[0]) ? i : 0);
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
free(uri);
free(full_uri);
@ -2620,7 +2620,7 @@ dacp_request(struct evhttp_request *req)
{
DPRINTF(E_LOG, L_DACP, "Could not allocate evbuffer for DACP reply\n");
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
free(uri);
free(full_uri);

View File

@ -251,7 +251,7 @@ rsp_send_error(struct evhttp_request *req, char *errmsg)
if (!evbuf)
{
evhttp_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");
return;
}
@ -747,7 +747,7 @@ rsp_stream(struct evhttp_request *req, char **uri, struct evkeyvalq *query)
ret = safe_atoi32(uri[2], &id);
if (ret < 0)
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
httpd_send_error(req, HTTP_BADREQUEST, "Bad Request");
else
httpd_stream_file(req, id);
}

View File

@ -4535,7 +4535,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
if (evhttp_request_get_command(req) != EVHTTP_REQ_GET)
{
DPRINTF(E_LOG, L_MPD, "Unsupported request type for artwork\n");
evhttp_send_error(req, HTTP_BADMETHOD, "Method not allowed");
httpd_send_error(req, HTTP_BADMETHOD, "Method not allowed");
return;
}
@ -4546,7 +4546,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
if (!decoded)
{
DPRINTF(E_LOG, L_MPD, "Bad artwork request with uri '%s'\n", uri);
evhttp_send_error(req, HTTP_BADREQUEST, 0);
httpd_send_error(req, HTTP_BADREQUEST, 0);
return;
}
@ -4554,7 +4554,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
if (!path)
{
DPRINTF(E_LOG, L_MPD, "Invalid path from artwork request with uri '%s'\n", uri);
evhttp_send_error(req, HTTP_BADREQUEST, 0);
httpd_send_error(req, HTTP_BADREQUEST, 0);
evhttp_uri_free(decoded);
return;
}
@ -4563,7 +4563,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
if (!decoded_path)
{
DPRINTF(E_LOG, L_MPD, "Error decoding path from artwork request with uri '%s'\n", uri);
evhttp_send_error(req, HTTP_BADREQUEST, 0);
httpd_send_error(req, HTTP_BADREQUEST, 0);
evhttp_uri_free(decoded);
return;
}
@ -4578,7 +4578,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
if (!itemid)
{
DPRINTF(E_WARN, L_MPD, "No item found for path '%s' from request uri '%s'\n", decoded_path, uri);
evhttp_send_error(req, HTTP_NOTFOUND, "Document was not found");
httpd_send_error(req, HTTP_NOTFOUND, "Document was not found");
evhttp_uri_free(decoded);
free(decoded_path);
return;
@ -4588,7 +4588,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
if (!evbuffer)
{
DPRINTF(E_LOG, L_MPD, "Could not allocate an evbuffer for artwork request\n");
evhttp_send_error(req, HTTP_INTERNAL, "Document was not found");
httpd_send_error(req, HTTP_INTERNAL, "Document was not found");
evhttp_uri_free(decoded);
free(decoded_path);
return;
@ -4597,7 +4597,7 @@ artwork_cb(struct evhttp_request *req, void *arg)
format = artwork_get_item(evbuffer, itemid, 600, 600);
if (format < 0)
{
evhttp_send_error(req, HTTP_NOTFOUND, "Document was not found");
httpd_send_error(req, HTTP_NOTFOUND, "Document was not found");
}
else
{