Permalink
Browse files

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

  • Loading branch information...
1 parent 23c8cc7 commit c3f4a12b3481d455a01049f28d949c17f2d868de Benoit Chesneau committed Dec 18, 2009
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/couchbeam_resource.erl
View
@@ -48,25 +48,26 @@ 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
[] -> [];
Props -> "?" ++ encode_query(Props)
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.