Commits

Anonymous committed d87c46e

An interim fix for PUT request bodies greater than 64M

  • Participants
  • Parent commits e9f2a29

Comments (0)

Files changed (3)

File include/wm_reqdata.hrl

 -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

File src/webmachine_request.erl

 %% @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 -> 
       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,