From 45fa308574d40b3ff6d58e8aaaf433517d96dc54 Mon Sep 17 00:00:00 2001 From: Pavel Abalihin Date: Tue, 2 Dec 2014 13:31:50 +0300 Subject: [PATCH] rewrite 'host' header on redirect --- src/hackney_client/hackney.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hackney_client/hackney.erl b/src/hackney_client/hackney.erl index 5845a82a..726204da 100644 --- a/src/hackney_client/hackney.erl +++ b/src/hackney_client/hackney.erl @@ -772,7 +772,9 @@ redirect(Client0, {Method, NewLocation, Headers, Body}) -> #hackney_url{transport=RedirectTransport, host=RedirectHost, port=RedirectPort}=RedirectUrl, - RedirectRequest = make_request(Method, RedirectUrl, Headers, Body, + NewHeaders = lists:keystore(<<"Host">>, 1, Headers, + {<<"Host">>, RedirectHost}), + RedirectRequest = make_request(Method, RedirectUrl, NewHeaders, Body, Client#client.options, false), %% make a request without any redirection #client{transport=Transport,