diff options
author | Ingela Anderton Andin <[email protected]> | 2016-09-28 11:22:05 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2016-09-28 11:22:05 +0200 |
commit | 470142dd4fa68168305653ec20648b89714fd5cf (patch) | |
tree | 847f74fe8e63f9f3672df0c65082010d1ca329fe /lib/inets/src/http_client/httpc_response.erl | |
parent | ee80c779c3ae7900e183c98f2568d386e03e3b66 (diff) | |
parent | 494f6335ffebd3efd3eb443f4a0bfdbb2702b8c4 (diff) | |
download | otp-470142dd4fa68168305653ec20648b89714fd5cf.tar.gz otp-470142dd4fa68168305653ec20648b89714fd5cf.tar.bz2 otp-470142dd4fa68168305653ec20648b89714fd5cf.zip |
Merge branch 'ahmedshafeeq/inets-httpc-RFC-7231/PR-1172/OTP-13902' into maint
* ahmedshafeeq/inets-httpc-RFC-7231/PR-1172/OTP-13902:
Update test case docs with RFC-7231
Update behavior of httpc:request to match RFC-7231
Diffstat (limited to 'lib/inets/src/http_client/httpc_response.erl')
-rw-r--r-- | lib/inets/src/http_client/httpc_response.erl | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index 91256fa6a2..d8bdac24e3 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -110,27 +110,30 @@ result(Response = {{_, 300, _}, _, _}, redirect(Response, Request); result(Response = {{_, Code, _}, _, _}, + Request = #request{settings = + #http_options{autoredirect = true}, + method = post}) when (Code =:= 301) orelse + (Code =:= 302) orelse + (Code =:= 303) -> + redirect(Response, Request#request{method = get}); +result(Response = {{_, Code, _}, _, _}, + Request = #request{settings = + #http_options{autoredirect = true}, + method = post}) when (Code =:= 307) -> + redirect(Response, Request); +result(Response = {{_, Code, _}, _, _}, Request = #request{settings = #http_options{autoredirect = true}, - method = head}) when (Code =:= 301) orelse + method = Method}) when (Code =:= 301) orelse (Code =:= 302) orelse (Code =:= 303) orelse (Code =:= 307) -> - redirect(Response, Request); -result(Response = {{_, Code, _}, _, _}, - Request = #request{settings = - #http_options{autoredirect = true}, - method = get}) when (Code =:= 301) orelse - (Code =:= 302) orelse - (Code =:= 303) orelse - (Code =:= 307) -> - redirect(Response, Request); -result(Response = {{_, 303, _}, _, _}, - Request = #request{settings = - #http_options{autoredirect = true}, - method = post}) -> - redirect(Response, Request#request{method = get}); - + case lists:member(Method, [get, head, options, trace]) of + true -> + redirect(Response, Request); + false -> + transparent(Response, Request) + end; result(Response = {{_,503,_}, _, _}, Request) -> status_service_unavailable(Response, Request); |