diff options
author | Loïc Hoguin <[email protected]> | 2013-09-02 20:05:03 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-09-02 20:05:03 +0200 |
commit | 67410731e09592fbc1b8658ef9da10ba43f4650d (patch) | |
tree | 743cd2f7b149a746b00d5df56f4ec047899da7a6 /src/cowboy_client.erl | |
parent | 9eab26d8353f1546ad8209196c36e42d616f952e (diff) | |
parent | d2adbf3de66f15dc0b654c76ee7bee7bd9c8c778 (diff) | |
download | cowboy-67410731e09592fbc1b8658ef9da10ba43f4650d.tar.gz cowboy-67410731e09592fbc1b8658ef9da10ba43f4650d.tar.bz2 cowboy-67410731e09592fbc1b8658ef9da10ba43f4650d.zip |
Merge branch 'ipv6-literal' of git://github.com/yamt/cowboy
Diffstat (limited to 'src/cowboy_client.erl')
-rw-r--r-- | src/cowboy_client.erl | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/cowboy_client.erl b/src/cowboy_client.erl index b5f96b3..10aaa9c 100644 --- a/src/cowboy_client.erl +++ b/src/cowboy_client.erl @@ -93,16 +93,19 @@ request(Method, URL, Headers, Body, Client=#client{ end, VersionBin = atom_to_binary(Version, latin1), %% @todo do keepalive too, allow override... - Headers2 = [ - {<<"host">>, FullHost}, + Headers2 = case lists:keyfind(<<"host">>, 1, Headers) of + false -> [{<<"host">>, FullHost}|Headers]; + _ -> Headers + end, + Headers3 = [ {<<"user-agent">>, <<"Cow">>} - |Headers], - Headers3 = case iolist_size(Body) of - 0 -> Headers2; - Length -> [{<<"content-length">>, integer_to_list(Length)}|Headers2] + |Headers2], + Headers4 = case iolist_size(Body) of + 0 -> Headers3; + Length -> [{<<"content-length">>, integer_to_list(Length)}|Headers3] end, HeadersData = [[Name, <<": ">>, Value, <<"\r\n">>] - || {Name, Value} <- Headers3], + || {Name, Value} <- Headers4], Data = [Method, <<" ">>, Path, <<" ">>, VersionBin, <<"\r\n">>, HeadersData, <<"\r\n">>, Body], raw_request(Data, Client2). |