From 063737e4f5158a52abde4388fa51a6a68ddcae51 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Mon, 14 May 2018 19:30:21 +0300 Subject: Optimize HTTP requests memory usage Due to historical reasons, ejabberd loads the whole file/data into the memory when serving an HTTP request. This is now improved: 1) For GET requests ejabberd uses sendfile(2) if the underlying connection is HTTP and falls back to read/write loop with 64kb buffer for HTTPS connections. This type of requests are handled by mod_http_fileserver, mod_http_upload, ejabberd_captcha, etc 2) POST requests are now limited to 20Mb and are fully downloaded into the memory for further processing (by ejabberd_web_admin, mod_bosh, etc) 3) PUT requests (e.g. for mod_http_upload) are handled by read/write loop with 64kb buffer --- include/ejabberd_http.hrl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ejabberd_http.hrl b/include/ejabberd_http.hrl index 3c38969ca..e0183a531 100644 --- a/include/ejabberd_http.hrl +++ b/include/ejabberd_http.hrl @@ -31,7 +31,10 @@ port = 5280 :: inet:port_number(), opts = [] :: list(), tp = http :: protocol(), - headers = [] :: [{atom() | binary(), binary()}]}). + headers = [] :: [{atom() | binary(), binary()}], + length = 0 :: non_neg_integer(), + sockmod :: gen_tcp | fast_tls, + socket :: inet:socket() | fast_tls:tls_socket()}). -record(ws, {socket :: inet:socket() | fast_tls:tls_socket(), -- cgit v1.2.3