[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] How to handle large uploads in the evhttp based server?



I'm writing a service using libevent 2.1.5 (beta) that needs to support relatively large (5-10GB) PUT requests (uploads) over local 10GB ethernet.
It'd be ideal if I could handle these in a chunked mode, just like when the client handles chunked replies, rather than consume memory or split it into zillions of small HTTP requests...

Along these lines (server side):
ÂÂ evhttp_accept_socket(http, nfd);
ÂÂ evhttp_set_cb(http, "/upload", http_upload, base);
ÂÂ
ÂÂ static void http_upload(struct evhttp_request *req, void *arg) {
ÂÂÂÂÂ if (evhttp_request_get_command(req) == EVHTTP_REQ_POST) {
ÂÂÂÂÂÂÂÂÂ evhttp_request set_chunked_cb(req, http_upload_chunk);
ÂÂÂÂÂ }
ÂÂ }

 static void http_upload_chunk(..) {handle uploaded chunk of data}

ÂÂ
I'm trying to do it, but evhttp_request set_chunked_cb  just complains it is in the client mode.
Is that by design? Just not implemented? Am I doing something wrong?


Cheers,
Dmitry