4646 request_async /6 ,
4747 request_async /7 ,
4848 request_async /8 ,
49+ request_async /9 ,
4950 stream_next /1 ,
5051 stop_async /1 ,
5152 pause_stream /1 ,
@@ -324,6 +325,11 @@ request_async(Pid, Method, Path, Headers, Body, AsyncMode, StreamTo) ->
324325request_async (Pid , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect ) ->
325326 gen_statem :call (Pid , {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect }).
326327
328+ -spec request_async (pid (), binary (), binary (), list (), binary () | iolist (), true | once , pid (), boolean (), list ()) ->
329+ {ok , reference ()} | {error , term ()}.
330+ request_async (Pid , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , ReqOpts ) ->
331+ gen_statem :call (Pid , {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , ReqOpts }).
332+
327333% % @doc Request the next message in {async, once} mode.
328334-spec stream_next (pid ()) -> ok | {error , term ()}.
329335stream_next (Pid ) ->
@@ -794,13 +800,19 @@ connected({call, From}, is_upgraded_ssl, #conn_data{upgraded_ssl = Upgraded}) ->
794800connected ({call , From }, is_no_reuse , # conn_data {no_reuse = NoReuse }) ->
795801 {keep_state_and_data , [{reply , From , NoReuse }]};
796802
797- connected ({call , From }, {request , Method , Path , Headers , Body , _ReqOpts }, # conn_data {protocol = http2 } = Data ) ->
803+ connected ({call , From }, {request , Method , Path , Headers , Body , ReqOpts }, # conn_data {protocol = http2 } = Data ) ->
798804 % % HTTP/2 request - use h2_machine (1xx not applicable for HTTP/2)
799- do_h2_request (From , Method , Path , Headers , Body , Data );
805+ % % Allow recv_timeout to be overridden per-request (fix for issue #832)
806+ RecvTimeout = proplists :get_value (recv_timeout , ReqOpts , Data # conn_data .recv_timeout ),
807+ NewData = Data # conn_data {recv_timeout = RecvTimeout },
808+ do_h2_request (From , Method , Path , Headers , Body , NewData );
800809
801- connected ({call , From }, {request , Method , Path , Headers , Body , _ReqOpts }, # conn_data {protocol = http3 } = Data ) ->
810+ connected ({call , From }, {request , Method , Path , Headers , Body , ReqOpts }, # conn_data {protocol = http3 } = Data ) ->
802811 % % HTTP/3 request - use hackney_h3 (1xx not applicable for HTTP/3)
803- do_h3_request (From , Method , Path , Headers , Body , Data );
812+ % % Allow recv_timeout to be overridden per-request (fix for issue #832)
813+ RecvTimeout = proplists :get_value (recv_timeout , ReqOpts , Data # conn_data .recv_timeout ),
814+ NewData = Data # conn_data {recv_timeout = RecvTimeout },
815+ do_h3_request (From , Method , Path , Headers , Body , NewData );
804816
805817connected ({call , From }, {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo }, # conn_data {protocol = http2 } = Data ) ->
806818 % % HTTP/2 async request
@@ -826,6 +838,8 @@ connected({call, From}, {request, Method, Path, Headers, Body, ReqOpts}, Data) -
826838 % % HTTP/1.1 request
827839 InformFun = proplists :get_value (inform_fun , ReqOpts , undefined ),
828840 AutoDecompress = proplists :get_value (auto_decompress , ReqOpts , false ),
841+ % % Allow recv_timeout to be overridden per-request (fix for issue #832)
842+ RecvTimeout = proplists :get_value (recv_timeout , ReqOpts , Data # conn_data .recv_timeout ),
829843 NewData = Data # conn_data {
830844 request_from = From ,
831845 method = Method ,
@@ -840,7 +854,8 @@ connected({call, From}, {request, Method, Path, Headers, Body, ReqOpts}, Data) -
840854 async_ref = undefined ,
841855 stream_to = undefined ,
842856 inform_fun = InformFun ,
843- auto_decompress = AutoDecompress
857+ auto_decompress = AutoDecompress ,
858+ recv_timeout = RecvTimeout
844859 },
845860 {next_state , sending , NewData , [{next_event , internal , {send_request , Method , Path , Headers , Body }}]};
846861
@@ -849,9 +864,27 @@ connected({call, From}, {request_async, Method, Path, Headers, Body, AsyncMode,
849864 do_request_async (From , Method , Path , Headers , Body , AsyncMode , StreamTo , false , Data );
850865
851866connected ({call , From }, {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect }, Data ) ->
852- % % Start a new async request with redirect option
867+ % % Start a new async request with redirect option (HTTP/1.1)
853868 do_request_async (From , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , Data );
854869
870+ connected ({call , From }, {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , ReqOpts }, # conn_data {protocol = http2 } = Data ) ->
871+ % % HTTP/2 async request with ReqOpts (fix for issue #832)
872+ RecvTimeout = proplists :get_value (recv_timeout , ReqOpts , Data # conn_data .recv_timeout ),
873+ NewData = Data # conn_data {recv_timeout = RecvTimeout },
874+ do_h2_request_async (From , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , NewData );
875+
876+ connected ({call , From }, {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo , _FollowRedirect , ReqOpts }, # conn_data {protocol = http3 } = Data ) ->
877+ % % HTTP/3 async request with ReqOpts (fix for issue #832, redirect not yet implemented for H3)
878+ RecvTimeout = proplists :get_value (recv_timeout , ReqOpts , Data # conn_data .recv_timeout ),
879+ NewData = Data # conn_data {recv_timeout = RecvTimeout },
880+ do_h3_request_async (From , Method , Path , Headers , Body , AsyncMode , StreamTo , NewData );
881+
882+ connected ({call , From }, {request_async , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , ReqOpts }, Data ) ->
883+ % % HTTP/1.1 async request with ReqOpts (fix for issue #832)
884+ RecvTimeout = proplists :get_value (recv_timeout , ReqOpts , Data # conn_data .recv_timeout ),
885+ NewData = Data # conn_data {recv_timeout = RecvTimeout },
886+ do_request_async (From , Method , Path , Headers , Body , AsyncMode , StreamTo , FollowRedirect , NewData );
887+
855888connected ({call , From }, {send_headers , Method , Path , Headers }, # conn_data {protocol = http3 } = Data ) ->
856889 % % HTTP/3 streaming body - send headers only via QUIC
857890 do_h3_send_headers (From , Method , Path , Headers , Data );
0 commit comments