Permalink
Browse files

Manually add a host header. This drags in amqp_client, but it's very …

…likely you're running that already.
  • Loading branch information...
1 parent 1eda12d commit 704aeed74ffee814861700cd26164bf18bb59586 Simon MacMullen committed Jan 16, 2013
Showing with 6 additions and 2 deletions.
  1. +5 −1 src/rabbit_auth_backend_http.erl
  2. +1 −1 src/rabbitmq_auth_backend_http.app.src
@@ -69,7 +69,11 @@ bool_req(PathName, Props) ->
end.
http_get(Path) ->
- case httpc:request(get, {Path, []}, ?HTTPC_OPTS, []) of
+ URI = uri_parser:parse(Path, [{port, 80}]),
+ {host, Host} = lists:keyfind(host, 1, URI),
+ {port, Port} = lists:keyfind(port, 1, URI),
+ HostHdr = rabbit_misc:format("~s:~b", [Host, Port]),
+ case httpc:request(get, {Path, [{"Host", HostHdr}]}, ?HTTPC_OPTS, []) of
{ok, {{_HTTP, Code, _}, _Headers, Body}} ->
case Code of
200 -> case parse_resp(Body) of
@@ -8,4 +8,4 @@
{env, [{user_path, "http://localhost:8000/auth/user"},
{vhost_path, "http://localhost:8000/auth/vhost"},
{resource_path, "http://localhost:8000/auth/resource"}] },
- {applications, [kernel, stdlib, inets]}]}.
+ {applications, [kernel, stdlib, inets, amqp_client]}]}.

0 comments on commit 704aeed

Please sign in to comment.