Skip to content

Commit

Permalink
use httpc instead of lhttpc when retrieving imds data
Browse files Browse the repository at this point in the history
  • Loading branch information
zerth committed Oct 20, 2014
1 parent d425480 commit d8f87f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/imds.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ get_session_token() ->
imds_response(Url, MimeTypes, Timeout) ->
AcceptHeader = {"Accept", string:join(MimeTypes, ", ")},
RequestHeaders = [AcceptHeader | ?IMDS_HEADERS],
case lhttpc:request(Url, "GET", RequestHeaders, Timeout) of
{ok, {{200, _}, Headers, Body}} ->
case httpc:request(get, {Url, RequestHeaders}, [{timeout, Timeout}], [{body_format, binary}]) of
{ok, {{_, 200, _}, Headers, Body}} ->
case lists:member(mime_type(Headers), MimeTypes) of
true ->
{ok, Body};
false ->
%% the server ignored our accept header:
{error, unacceptable_response}
end;
{ok, {{406, _}, _, _}} ->
{ok, {{_, 406, _}, _, _}} ->
%% the server respected our accept header and could not
%% produce a response with any of the requested mime
%% types:
{error, unacceptable_response};
{ok, {{Code, Status}, _, _}} ->
{ok, {{_, Code, Status}, _, _}} ->
{error, {bad_response, {Code, Status}}};
{error, Reason} ->
{error, Reason}
Expand Down

0 comments on commit d8f87f8

Please sign in to comment.