Permalink
Browse files

An interim fix for PUT request bodies greater than 64M

  • Loading branch information...
1 parent caf4e7e commit 4f390c5b63f16c00d28d31c00618aefc0cbeb2d9 Ryan Tilder committed Mar 19, 2010
Showing with 5 additions and 2 deletions.
  1. +1 −1 include/wm_reqdata.hrl
  2. +2 −1 src/webmachine_request.erl
  3. +2 −0 src/wrq.erl
View
@@ -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
@@ -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 ->
View
@@ -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,

0 comments on commit 4f390c5

Please sign in to comment.