Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix Host header. It fixes the issue with cloudant connection.

  • Loading branch information...
commit c3f4a12b3481d455a01049f28d949c17f2d868de 1 parent 23c8cc7
Benoit Chesneau authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/couchbeam_resource.erl
View
11 src/couchbeam_resource.erl
@@ -48,7 +48,7 @@ put(State, Path, Headers, Params, Body, Opts) ->
request(State, "PUT", Path, Headers, Params, Body, Opts).
-request(State, Method, Path, Headers, Params, Body, Options) ->
+request(#couchdb_params{host=Host, port=Port}=State, Method, Path, Headers, Params, Body, Options) ->
Path1 = lists:append([Path,
case Params of
[] -> [];
@@ -56,17 +56,18 @@ request(State, Method, Path, Headers, Params, Body, Options) ->
end]),
Headers1 = make_auth(State, Headers),
Headers2 = default_header("Content-Type", "application/json", Headers1),
+ Headers3 = default_header("Host", Host++":"++ integer_to_list(Port), Headers2),
case has_body(Method) of
true ->
- case make_body(Body, Headers2, Options) of
- {Headers3, Options1, InitialBody, BodyFun} ->
- do_request(State, Method, Path1, Headers3, {BodyFun, InitialBody}, Options1);
+ case make_body(Body, Headers3, Options) of
+ {Headers4, Options1, InitialBody, BodyFun} ->
+ do_request(State, Method, Path1, Headers4, {BodyFun, InitialBody}, Options1);
Error ->
Error
end;
false ->
- do_request(State, Method, Path1, Headers2, {nil, <<>>}, Options)
+ do_request(State, Method, Path1, Headers3, {nil, <<>>}, Options)
end.

0 comments on commit c3f4a12

Please sign in to comment.
Something went wrong with that request. Please try again.