mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
Add a variant of evhttp_send_reply_chunk() with a callback on evhttp_write_buffer()
evhttp_write_buffer() used by evhttp_send_reply_chunk() can take callback executed when (part of) the buffer has been written. Using this callback to schedule the next chunk avoids buffering large amounts of data in memory.
This commit is contained in:
parent
1d152decf7
commit
7a37732658
@ -64,6 +64,7 @@ extern "C" {
|
||||
struct evhttp;
|
||||
struct evhttp_request;
|
||||
struct evkeyvalq;
|
||||
struct evhttp_connection;
|
||||
|
||||
/** Create a new HTTP server
|
||||
*
|
||||
@ -159,6 +160,8 @@ void evhttp_send_reply(struct evhttp_request *req, int code,
|
||||
|
||||
/* Low-level response interface, for streaming/chunked replies */
|
||||
void evhttp_send_reply_start(struct evhttp_request *, int, const char *);
|
||||
void evhttp_send_reply_chunk_with_cb(struct evhttp_request *, struct evbuffer *,
|
||||
void (*cb)(struct evhttp_connection *, void *), void *arg);
|
||||
void evhttp_send_reply_chunk(struct evhttp_request *, struct evbuffer *);
|
||||
void evhttp_send_reply_end(struct evhttp_request *);
|
||||
|
||||
|
@ -1963,7 +1963,8 @@ evhttp_send_reply_start(struct evhttp_request *req, int code,
|
||||
}
|
||||
|
||||
void
|
||||
evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
evhttp_send_reply_chunk_with_cb(struct evhttp_request *req, struct evbuffer *databuf,
|
||||
void (*cb)(struct evhttp_connection *, void *), void *arg)
|
||||
{
|
||||
if (req->chunked) {
|
||||
evbuffer_add_printf(req->evcon->output_buffer, "%x\r\n",
|
||||
@ -1973,7 +1974,13 @@ evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
if (req->chunked) {
|
||||
evbuffer_add(req->evcon->output_buffer, "\r\n", 2);
|
||||
}
|
||||
evhttp_write_buffer(req->evcon, NULL, NULL);
|
||||
evhttp_write_buffer(req->evcon, cb, arg);
|
||||
}
|
||||
|
||||
void
|
||||
evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
|
||||
{
|
||||
evhttp_send_reply_chunk_with_cb(req, databuf, NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user