diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-02-01 17:20:41 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2016-02-01 17:20:41 -0500 |
commit | a229a21ffb5af043ade5c3834a669378e3a9658f (patch) | |
tree | 320a79498ded79d141568b680c89cfc563b3d3df | |
parent | fceda519992728f3f6b3264adfee59af61b7104d (diff) | |
parent | 9cf84e5379273a49f8e0942d7b2c291c1ee7deba (diff) |
Merge pull request #1046 from tsloughter/user-agent
add user-agent to http request headers
-rw-r--r-- | src/rebar_pkg_resource.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_update.erl | 2 | ||||
-rw-r--r-- | src/rebar_utils.erl | 7 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/rebar_pkg_resource.erl b/src/rebar_pkg_resource.erl index 33687e4..ec7e09d 100644 --- a/src/rebar_pkg_resource.erl +++ b/src/rebar_pkg_resource.erl @@ -104,7 +104,7 @@ make_vsn(_) -> {error, "Replacing version of type pkg not supported."}. request(Url, ETag) -> - case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]}, + case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]++[{"User-Agent", rebar_utils:user_agent()}]}, [{ssl, ssl_opts(Url)}, {relaxed, true}], [{body_format, binary}], rebar) of diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl index 1cdf6af..0e3b9a0 100644 --- a/src/rebar_prv_update.erl +++ b/src/rebar_prv_update.erl @@ -48,7 +48,7 @@ do(State) -> case rebar_utils:url_append_path(CDN, ?REMOTE_REGISTRY_FILE) of {ok, Url} -> ?DEBUG("Fetching registry from ~p", [Url]), - case httpc:request(get, {Url, []}, + case httpc:request(get, {Url, [{"User-Agent", rebar_utils:user_agent()}]}, [], [{stream, TmpFile}, {sync, true}], rebar) of {ok, saved_to_file} -> diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 07bf789..56a3940 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -68,7 +68,8 @@ check_min_otp_version/1, check_blacklisted_otp_versions/1, info_useless/2, - list_dir/1]). + list_dir/1, + user_agent/0]). %% for internal use only -export([otp_release/0]). @@ -407,6 +408,10 @@ abort_if_blacklisted(BlacklistedRegex, OtpRelease) -> [OtpRelease, BlacklistedRegex]) end. +user_agent() -> + {ok, Vsn} = application:get_key(rebar, vsn), + ?FMT("Rebar/~s (OTP/~s)", [Vsn, otp_release()]). + %% ==================================================================== %% Internal functions %% ==================================================================== |