@@ -33,11 +33,14 @@ perform(Client0, {Method0, Path, Headers0, Body0}) ->
33
33
# client {options = Options } = Client0 ,
34
34
35
35
% % basic & Cookies authorization handling
36
+ UseLibHeaders = proplists :get_value (lib_headers , Options ),
36
37
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 , _ } ->
39
42
maybe_add_cookies (Cookies , [{<<" User-Agent" >>, default_ua ()}]);
40
- {User , Pwd } ->
43
+ {{ User , Pwd }, _ } ->
41
44
User1 = hackney_bstr :to_binary (User ),
42
45
Pwd1 = hackney_bstr :to_binary (Pwd ),
43
46
Credentials = base64 :encode (<< User1 /binary , " :" , Pwd1 /binary >>),
@@ -55,13 +58,13 @@ perform(Client0, {Method0, Path, Headers0, Body0}) ->
55
58
),
56
59
57
60
% % add host eventually
58
- Headers2 = maybe_add_host (Headers1 , Client0 # client .netloc ),
61
+ Headers2 = maybe_add_host (Headers1 , Client0 # client .netloc , UseLibHeaders ),
59
62
60
63
% % get expect headers
61
64
Expect = expectation (Headers2 ),
62
65
63
66
% % build headers with the body.
64
- {FinalHeaders , ReqType , Body , Client1 } = case Body0 of
67
+ {Headers3 , ReqType , Body , Client1 } = case Body0 of
65
68
stream ->
66
69
{Headers2 , ReqType0 , stream , Client0 };
67
70
stream_multipart ->
@@ -81,6 +84,13 @@ perform(Client0, {Method0, Path, Headers0, Body0}) ->
81
84
handle_body (Headers2 , ReqType0 , Body0 , Client0 )
82
85
end ,
83
86
87
+ FinalHeaders = case UseLibHeaders of
88
+ none ->
89
+ Headers2 ;
90
+ _ ->
91
+ Headers3
92
+ end ,
93
+
84
94
% % build final client record
85
95
Client = case ReqType of
86
96
normal ->
@@ -616,7 +626,9 @@ default_ua() ->
616
626
end ,
617
627
<< " hackney/" , Version /binary >>.
618
628
619
- maybe_add_host (Headers0 , Netloc ) ->
629
+ maybe_add_host (Headers , Netloc , none ) ->
630
+ Headers ;
631
+ maybe_add_host (Headers0 , Netloc , _ ) ->
620
632
{_ , Headers1 } = hackney_headers_new :store_new (<<" Host" >>, Netloc , Headers0 ),
621
633
Headers1 .
622
634
0 commit comments