浏览代码

add user-agent to http request headers

pull/1046/head
Tristan Sloughter 9 年前
父节点
当前提交
9cf84e5379
共有 3 个文件被更改,包括 8 次插入3 次删除
  1. +1
    -1
      src/rebar_pkg_resource.erl
  2. +1
    -1
      src/rebar_prv_update.erl
  3. +6
    -1
      src/rebar_utils.erl

+ 1
- 1
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

+ 1
- 1
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} ->

+ 6
- 1
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
%% ====================================================================

正在加载...
取消
保存