mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-26 04:49:18 -05:00
[httpd] Allow caller of httpd_send_reply to avoid gzipping
This commit is contained in:
parent
d8696e72ea
commit
249d923af2
@ -757,7 +757,7 @@ httpd_stream_file(struct evhttp_request *req, int id)
|
||||
|
||||
/* Thread: httpd */
|
||||
void
|
||||
httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *evbuf)
|
||||
httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *evbuf, enum httpd_send_flags flags)
|
||||
{
|
||||
struct evbuffer *gzbuf;
|
||||
struct evkeyvalq *input_headers;
|
||||
@ -772,7 +772,8 @@ httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struc
|
||||
input_headers = evhttp_request_get_input_headers(req);
|
||||
output_headers = evhttp_request_get_output_headers(req);
|
||||
|
||||
do_gzip = ( evbuf && (evbuffer_get_length(evbuf) > 512) &&
|
||||
do_gzip = ( (!(flags & HTTPD_SEND_NO_GZIP)) &&
|
||||
evbuf && (evbuffer_get_length(evbuf) > 512) &&
|
||||
(param = evhttp_find_header(input_headers, "Accept-Encoding")) &&
|
||||
(strstr(param, "gzip") || strstr(param, "*"))
|
||||
);
|
||||
|
@ -5,11 +5,16 @@
|
||||
#include <event2/http.h>
|
||||
#include <event2/buffer.h>
|
||||
|
||||
enum httpd_send_flags
|
||||
{
|
||||
HTTPD_SEND_NO_GZIP = (1 << 0),
|
||||
};
|
||||
|
||||
void
|
||||
httpd_stream_file(struct evhttp_request *req, int id);
|
||||
|
||||
void
|
||||
httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *evbuf);
|
||||
httpd_send_reply(struct evhttp_request *req, int code, const char *reason, struct evbuffer *evbuf, enum httpd_send_flags flags);
|
||||
|
||||
char *
|
||||
httpd_fixup_uri(struct evhttp_request *req);
|
||||
|
@ -355,7 +355,7 @@ update_refresh_cb(int fd, short event, void *arg)
|
||||
evcon = evhttp_request_get_connection(ur->req);
|
||||
evhttp_connection_set_closecb(evcon, NULL, NULL);
|
||||
|
||||
httpd_send_reply(ur->req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(ur->req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
update_remove(ur);
|
||||
}
|
||||
@ -882,7 +882,7 @@ daap_reply_server_info(struct evhttp_request *req, struct evbuffer *evbuf, char
|
||||
evbuffer_add_buffer(evbuf, content);
|
||||
evbuffer_free(content);
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -924,7 +924,7 @@ daap_reply_content_codes(struct evhttp_request *req, struct evbuffer *evbuf, cha
|
||||
dmap_add_short(evbuf, "mcty", dmap_fields[i].type); /* 10 */
|
||||
}
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -999,7 +999,7 @@ daap_reply_login(struct evhttp_request *req, struct evbuffer *evbuf, char **uri,
|
||||
dmap_add_int(evbuf, "mstt", 200); /* 12 */
|
||||
dmap_add_int(evbuf, "mlid", s->id); /* 12 */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1015,7 +1015,7 @@ daap_reply_logout(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
|
||||
|
||||
daap_session_remove(s);
|
||||
|
||||
httpd_send_reply(req, 204, "Logout Successful", evbuf);
|
||||
httpd_send_reply(req, 204, "Logout Successful", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1068,7 +1068,7 @@ daap_reply_update(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
|
||||
dmap_add_int(evbuf, "mstt", 200); /* 12 */
|
||||
dmap_add_int(evbuf, "musr", current_rev); /* 12 */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1222,7 +1222,7 @@ daap_reply_dblist(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
|
||||
evbuffer_add_buffer(evbuf, content);
|
||||
evbuffer_free(content);
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1510,7 +1510,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
||||
}
|
||||
}
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1821,7 +1821,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
return -1;
|
||||
}
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -2132,7 +2132,7 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
|
||||
}
|
||||
}
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -2338,7 +2338,7 @@ daap_reply_browse(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
|
||||
}
|
||||
}
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -2853,7 +2853,7 @@ daap_request(struct evhttp_request *req)
|
||||
ret = cache_daap_get(full_uri, evbuf);
|
||||
if (ret == 0)
|
||||
{
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf); // TODO not all want this reply
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0); // TODO not all want this reply
|
||||
|
||||
evbuffer_free(evbuf);
|
||||
free(uri);
|
||||
|
@ -368,10 +368,10 @@ playstatusupdate_cb(int fd, short what, void *arg)
|
||||
{
|
||||
buf = evbuffer_pullup(update, -1);
|
||||
evbuffer_add(evbuf, buf, len);
|
||||
httpd_send_reply(ur->req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(ur->req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
else
|
||||
httpd_send_reply(ur->req, HTTP_OK, "OK", update);
|
||||
httpd_send_reply(ur->req, HTTP_OK, "OK", update, 0);
|
||||
|
||||
free(ur);
|
||||
}
|
||||
@ -774,7 +774,7 @@ dacp_reply_ctrlint(struct evhttp_request *req, struct evbuffer *evbuf, char **ur
|
||||
dmap_add_char(evbuf, "cmrl", 1); /* 9, unknown */
|
||||
dmap_add_long(evbuf, "ceSX", (1 << 1 | 1)); /* 16, unknown dacp - lowest bit announces support for playqueue-contents/-edit */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1103,7 +1103,7 @@ dacp_reply_cue_play(struct evhttp_request *req, struct evbuffer *evbuf, char **u
|
||||
dmap_add_int(evbuf, "mstt", 200); /* 12 */
|
||||
dmap_add_int(evbuf, "miid", id); /* 12 */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1119,7 +1119,7 @@ dacp_reply_cue_clear(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
dmap_add_int(evbuf, "mstt", 200); /* 12 */
|
||||
dmap_add_int(evbuf, "miid", 0); /* 12 */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1673,7 +1673,7 @@ dacp_reply_playqueuecontents(struct evhttp_request *req, struct evbuffer *evbuf,
|
||||
dmap_add_char(evbuf, "apsm", status.shuffle); /* 9, daap.playlistshufflemode - not part of mlcl container */
|
||||
dmap_add_char(evbuf, "aprm", status.repeat); /* 9, daap.playlistrepeatmode - not part of mlcl container */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1697,7 +1697,7 @@ dacp_reply_playqueueedit_clear(struct evhttp_request *req, struct evbuffer *evbu
|
||||
dmap_add_int(evbuf, "mstt", 200); /* 12 */
|
||||
dmap_add_int(evbuf, "miid", 0); /* 12 */
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2025,7 +2025,7 @@ dacp_reply_playstatusupdate(struct evhttp_request *req, struct evbuffer *evbuf,
|
||||
if (ret < 0)
|
||||
evhttp_send_error(req, 500, "Internal Server Error");
|
||||
else
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -2243,7 +2243,7 @@ dacp_reply_getproperty(struct evhttp_request *req, struct evbuffer *evbuf, char
|
||||
return;
|
||||
}
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
return;
|
||||
|
||||
@ -2354,7 +2354,7 @@ dacp_reply_getspeakers(struct evhttp_request *req, struct evbuffer *evbuf, char
|
||||
|
||||
evbuffer_free(spklist);
|
||||
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -283,7 +283,7 @@ rsp_send_reply(struct evhttp_request *req, mxml_node_t *reply)
|
||||
headers = evhttp_request_get_output_headers(req);
|
||||
evhttp_add_header(headers, "Content-Type", "text/xml; charset=utf-8");
|
||||
evhttp_add_header(headers, "Connection", "close");
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
httpd_send_reply(req, HTTP_OK, "OK", evbuf, 0);
|
||||
|
||||
evbuffer_free(evbuf);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user