@@ -33,11 +33,14 @@ perform(Client0, {Method0, Path, Headers0, Body0}) ->
3333 # client {options = Options } = Client0 ,
3434
3535 % % basic & Cookies authorization handling
36+ UseLibHeaders = proplists :get_value (lib_headers , Options ),
3637 Cookies = proplists :get_value (cookie , Options , []),
37- DefaultHeaders = case proplists :get_value (basic_auth , Options ) of
38- undefined ->
38+ DefaultHeaders = case {proplists :get_value (basic_auth , Options ), UseLibHeaders } of
39+ {_ , none } ->
40+ [];
41+ {undefined , _ } ->
3942 maybe_add_cookies (Cookies , [{<<" User-Agent" >>, default_ua ()}]);
40- {User , Pwd } ->
43+ {{ User , Pwd }, _ } ->
4144 User1 = hackney_bstr :to_binary (User ),
4245 Pwd1 = hackney_bstr :to_binary (Pwd ),
4346 Credentials = base64 :encode (<< User1 /binary , " :" , Pwd1 /binary >>),
@@ -55,13 +58,13 @@ perform(Client0, {Method0, Path, Headers0, Body0}) ->
5558 ),
5659
5760 % % add host eventually
58- Headers2 = maybe_add_host (Headers1 , Client0 # client .netloc ),
61+ Headers2 = maybe_add_host (Headers1 , Client0 # client .netloc , UseLibHeaders ),
5962
6063 % % get expect headers
6164 Expect = expectation (Headers2 ),
6265
6366 % % build headers with the body.
64- {FinalHeaders , ReqType , Body , Client1 } = case Body0 of
67+ {Headers3 , ReqType , Body , Client1 } = case Body0 of
6568 stream ->
6669 {Headers2 , ReqType0 , stream , Client0 };
6770 stream_multipart ->
@@ -81,6 +84,13 @@ perform(Client0, {Method0, Path, Headers0, Body0}) ->
8184 handle_body (Headers2 , ReqType0 , Body0 , Client0 )
8285 end ,
8386
87+ FinalHeaders = case UseLibHeaders of
88+ none ->
89+ Headers2 ;
90+ _ ->
91+ Headers3
92+ end ,
93+
8494 % % build final client record
8595 Client = case ReqType of
8696 normal ->
@@ -616,7 +626,9 @@ default_ua() ->
616626 end ,
617627 << " hackney/" , Version /binary >>.
618628
619- maybe_add_host (Headers0 , Netloc ) ->
629+ maybe_add_host (Headers , Netloc , none ) ->
630+ Headers ;
631+ maybe_add_host (Headers0 , Netloc , _ ) ->
620632 {_ , Headers1 } = hackney_headers_new :store_new (<<" Host" >>, Netloc , Headers0 ),
621633 Headers1 .
622634
0 commit comments