Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:18
hackney
hackney-1.20.1-git.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hackney-1.20.1-git.patch of Package hackney
diff --git a/include/hackney.hrl b/include/hackney.hrl index d2c970c..b26951e 100644 --- a/include/hackney.hrl +++ b/include/hackney.hrl @@ -57,4 +57,5 @@ -define(CONNECTIONS, hackney_connections). --define(PROXY_ENV_VARS, ["http_proxy", "https_proxy", "HTTP_PROXY", "HTTPS_PROXY"]). +-define(HTTP_PROXY_ENV_VARS, ["http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY"]). +-define(HTTPS_PROXY_ENV_VARS, ["https_proxy", "HTTPS_PROXY", "all_proxy", "ALL_PROXY"]). diff --git a/rebar.config b/rebar.config index b818204..c9e6561 100644 --- a/rebar.config +++ b/rebar.config @@ -23,7 +23,7 @@ {deps, [ {idna, "~>6.1.0"}, {mimerl, "~>1.1"}, - {certifi, "~>2.12.0"}, + {certifi, "~>2.13.0"}, {metrics, "~>1.0.0"}, {parse_trans, "3.4.1"}, {ssl_verify_fun, "~>1.1.0"}, diff --git a/src/hackney.erl b/src/hackney.erl index 6a88b1b..7dbef23 100644 --- a/src/hackney.erl +++ b/src/hackney.erl @@ -320,7 +320,8 @@ request(Method, #hackney_url{}=URL0, Headers0, Body, Options0) -> host = Host, port = Port, user = User, - password = Password} = URL, + password = Password, + scheme = Scheme} = URL, Options = case User of <<>> -> @@ -332,7 +333,7 @@ request(Method, #hackney_url{}=URL0, Headers0, Body, Options0) -> Headers1 = hackney_headers_new:new(Headers0), - case maybe_proxy(Transport, Host, Port, Options) of + case maybe_proxy(Transport, Scheme, Host, Port, Options) of {ok, Ref, AbsolutePath} -> Request = make_request( Method, URL, Headers1, Body, Options, AbsolutePath @@ -615,7 +616,7 @@ make_request(Method, #hackney_url{}=URL, Headers, Body, _, _) -> {Method, FinalPath, Headers1, Body}. -maybe_proxy(Transport, Host, Port, Options) +maybe_proxy(Transport, Scheme, Host, Port, Options) when is_list(Host), is_integer(Port), is_list(Options) -> case proplists:get_value(proxy, Options) of Url when is_binary(Url) orelse is_list(Url) -> @@ -671,14 +672,14 @@ maybe_proxy(Transport, Host, Port, Options) NoProxyEnv = proplists:get_value( no_proxy_env, Options, application:get_env(hackney, no_proxy_env, false) ), - maybe_proxy_from_env(Transport, Host, Port, Options, NoProxyEnv) + maybe_proxy_from_env(Transport, Scheme, Host, Port, Options, NoProxyEnv) end. -maybe_proxy_from_env(Transport, Host, Port, Options, true) -> +maybe_proxy_from_env(Transport, _Scheme, Host, Port, Options, true) -> ?report_debug("request without proxy", []), hackney_connect:connect(Transport, Host, Port, Options, true); -maybe_proxy_from_env(Transport, Host, Port, Options, _) -> - case get_proxy_env() of +maybe_proxy_from_env(Transport, Scheme, Host, Port, Options, _) -> + case get_proxy_env(Scheme) of {ok, Url} -> proxy_from_url(Url, Transport, Host, Port, Options); false -> @@ -704,8 +705,10 @@ proxy_from_url(Url, Transport, Host, Port, Options) -> end end. -get_proxy_env() -> - get_proxy_env(?PROXY_ENV_VARS). +get_proxy_env(https) -> + get_proxy_env(?HTTPS_PROXY_ENV_VARS); +get_proxy_env(S) when S =:= http; S =:= http_unix -> + get_proxy_env(?HTTP_PROXY_ENV_VARS); get_proxy_env([Var | Rest]) -> case os:getenv(Var) of diff --git a/src/hackney_http.erl b/src/hackney_http.erl index 63e1b58..d37b5f9 100644 --- a/src/hackney_http.erl +++ b/src/hackney_http.erl @@ -152,7 +152,8 @@ execute(#hparser{state=Status, buffer=Buffer}=St, Bin) -> on_first_line -> parse_first_line(NBuffer, St1, 0); on_header -> parse_headers(St1); on_body -> parse_body(St1); - on_trailers -> parse_trailers(St1) + on_trailers -> parse_trailers(St1); + on_junk -> skip_junks(St1) end. %% Empty lines must be using \r\n. @@ -181,7 +182,13 @@ parse_first_line(Buffer, St=#hparser{type=Type, {error, bad_request} -> parse_response_line(St) end; _ when Type =:= response -> - parse_response_line(St); + case parse_response_line(St) of + {error, bad_request} -> {error, bad_request}; + {response, Version, StatusInt, Reason, NState} when StatusInt >= 200 -> + {response, Version, StatusInt, Reason, NState}; + {response, _Version, _StatusInt, _Reason, _NState} -> + {more, St#hparser{empty_lines=Empty, state=on_junk}} + end; _ when Type =:= request -> parse_request_line(St) end. @@ -343,6 +350,16 @@ parse_header(Line, St) -> parse_header_value(H) -> hackney_bstr:trim(H). +skip_junks(#hparser{buffer=Buf}=St) -> + case binary:split(Buf, <<"\r\n">>) of + [<<>>, Rest] -> + {more, St#hparser{buffer=Rest, state=on_first_line}}; + [_Line, Rest]-> + skip_junks(St#hparser{buffer=Rest}); + [Buf] -> + {more, St} + end. + parse_trailers(St) -> case parse_trailers(St, []) of {ok, _Trailers, #hparser{buffer=Rest1}} ->
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor