@@ -921,26 +921,36 @@ defmodule Mint.HTTP do
921
921
}
922
922
def recv_response ( conn , ref , timeout )
923
923
when is_reference ( ref ) and Util . is_timeout ( timeout ) do
924
- recv_response ( [ ] , % { status: nil , headers: [ ] , body: "" } , conn , ref , timeout )
924
+ recv_response ( [ ] , { nil , [ ] , "" } , conn , ref , timeout )
925
925
end
926
926
927
- defp recv_response ( [ { :status , ref , status } | rest ] , acc , conn , ref , timeout ) do
928
- acc = put_in ( acc . status , status )
929
- recv_response ( rest , acc , conn , ref , timeout )
927
+ defp recv_response (
928
+ [ { :status , ref , new_status } | rest ] ,
929
+ { _status , headers , body } ,
930
+ conn ,
931
+ ref ,
932
+ timeout
933
+ ) do
934
+ recv_response ( rest , { new_status , headers , body } , conn , ref , timeout )
930
935
end
931
936
932
- defp recv_response ( [ { :headers , ref , headers } | rest ] , acc , conn , ref , timeout ) do
933
- acc = update_in ( acc . headers , & ( & 1 ++ headers ) )
934
- recv_response ( rest , acc , conn , ref , timeout )
937
+ defp recv_response (
938
+ [ { :headers , ref , new_headers } | rest ] ,
939
+ { status , headers , body } ,
940
+ conn ,
941
+ ref ,
942
+ timeout
943
+ ) do
944
+ recv_response ( rest , { status , headers ++ new_headers , body } , conn , ref , timeout )
935
945
end
936
946
937
- defp recv_response ( [ { :data , ref , data } | rest ] , acc , conn , ref , timeout ) do
938
- acc = update_in ( acc . body , & ( & 1 <> data ) )
939
- recv_response ( rest , acc , conn , ref , timeout )
947
+ defp recv_response ( [ { :data , ref , data } | rest ] , { status , headers , body } , conn , ref , timeout ) do
948
+ recv_response ( rest , { status , headers , [ body , data ] } , conn , ref , timeout )
940
949
end
941
950
942
- defp recv_response ( [ { :done , ref } | _rest ] , acc , conn , ref , _timeout ) do
943
- { :ok , conn , acc }
951
+ defp recv_response ( [ { :done , ref } | _rest ] , { status , headers , body } , conn , ref , _timeout ) do
952
+ response = % { status: status , headers: headers , body: IO . iodata_to_binary ( body ) }
953
+ { :ok , conn , response }
944
954
end
945
955
946
956
defp recv_response ( [ { :error , ref , error } | _rest ] , _acc , conn , ref , _timeout ) do
0 commit comments