Skip to content

Commit

Permalink
An interim fix for PUT request bodies greater than 64M
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Tilder committed Mar 19, 2010
1 parent caf4e7e commit 4f390c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/wm_reqdata.hrl
@@ -1,6 +1,6 @@
-record(wm_reqdata, {method, version, peer, wm_state,
disp_path, path, raw_path, path_info, path_tokens,
app_root,response_code,max_recv_body,
app_root,response_code,max_recv_body, max_recv_hunk,
req_cookie, req_qs, req_headers, req_body,
resp_redirect, resp_headers, resp_body,
host_tokens, port
Expand Down
3 changes: 2 additions & 1 deletion src/webmachine_request.erl
Expand Up @@ -359,8 +359,9 @@ body_length() ->
%% @doc Receive the body of the HTTP request (defined by Content-Length).
%% Will only receive up to the default max-body length
do_recv_body(PassedState=#wm_reqstate{reqdata=RD}) ->
MRH = RD#wm_reqdata.max_recv_hunk,
MRB = RD#wm_reqdata.max_recv_body,
read_whole_stream(recv_stream_body(PassedState, MRB), [], MRB, 0).
read_whole_stream(recv_stream_body(PassedState, MRH), [], MRB, 0).

read_whole_stream({Hunk,_}, _, MaxRecvBody, SizeAcc)
when SizeAcc + byte_size(Hunk) > MaxRecvBody ->
Expand Down
2 changes: 2 additions & 0 deletions src/wrq.erl
Expand Up @@ -45,6 +45,8 @@ create(Method,Version,RawPath,Headers) ->
peer="defined_in_wm_req_srv_init",
req_body=not_fetched_yet,
max_recv_body=(1024*(1024*1024)),
% Stolen from R13B03 inet_drv.c's TCP_MAX_PACKET_SIZE definition
max_recv_hunk=(64*(1024*1024)),
app_root="defined_in_load_dispatch_data",
path_info=dict:new(),
path_tokens=defined_in_load_dispatch_data,
Expand Down

0 comments on commit 4f390c5

Please sign in to comment.