瀏覽代碼

setup hex httpc profile and http opts. needed also for proxy

pull/565/head
Tristan Sloughter 9 年之前
父節點
當前提交
1c66f0eb9f
共有 3 個文件被更改,包括 17 次插入6 次删除
  1. +11
    -1
      src/rebar3.erl
  2. +2
    -1
      src/rebar_pkg_resource.erl
  3. +4
    -4
      test/rebar_pkg_SUITE.erl

+ 11
- 1
src/rebar3.erl 查看文件

@ -272,4 +272,14 @@ start_and_load_apps() ->
application:start(asn1),
application:start(public_key),
application:start(ssl),
inets:start().
inets:start(),
inets:start(httpc, [{profile, hex}]),
http_opts().
http_opts() ->
Opts = [{max_sessions, 4},
{max_keep_alive_length, 4},
{keep_alive_timeout, 120000},
{max_pipeline_length, 4},
{pipeline_timeout, 60000}],
httpc:set_options(Opts, hex).

+ 2
- 1
src/rebar_pkg_resource.erl 查看文件

@ -95,7 +95,8 @@ make_vsn(_) ->
request(Url, ETag) ->
case httpc:request(get, {Url, [{"if-none-match", ETag} || ETag =/= false]},
[{relaxed, true}],
[{body_format, binary}]) of
[{body_format, binary}],
hex) of
{ok, {{_Version, 200, _Reason}, Headers, Body}} ->
?DEBUG("Successfully downloaded ~s", [Url]),
{"etag", ETag1} = lists:keyfind("etag", 1, Headers),

+ 4
- 4
test/rebar_pkg_SUITE.erl 查看文件

@ -61,7 +61,7 @@ init_per_testcase(good_disconnect=Name, Config0) ->
copy_to_cache(Pkg, Config),
meck:unload(httpc),
meck:new(httpc, [passthrough, unsticky]),
meck:expect(httpc, request, fun(_, _, _, _) -> {error, econnrefused} end),
meck:expect(httpc, request, fun(_, _, _, _, _) -> {error, econnrefused} end),
Config;
init_per_testcase(bad_disconnect=Name, Config0) ->
Pkg = {<<"goodpkg">>, <<"1.0.0">>},
@ -71,7 +71,7 @@ init_per_testcase(bad_disconnect=Name, Config0) ->
Config = mock_config(Name, Config1),
meck:unload(httpc),
meck:new(httpc, [passthrough, unsticky]),
meck:expect(httpc, request, fun(_, _, _, _) -> {error, econnrefused} end),
meck:expect(httpc, request, fun(_, _, _, _, _) -> {error, econnrefused} end),
Config.
end_per_testcase(_, Config) ->
@ -186,9 +186,9 @@ mock_config(Name, Config) ->
{ok, PkgContents} = file:read_file(filename:join(?config(data_dir, Config), PkgFile)),
meck:new(httpc, [passthrough, unsticky]),
meck:expect(httpc, request,
fun(get, {_Url, _Opts}, _, _) when GoodCache ->
fun(get, {_Url, _Opts}, _, _, _) when GoodCache ->
{ok, {{Vsn, 304, <<"Not Modified">>}, [{"etag", ?good_etag}], <<>>}};
(get, {_Url, _Opts}, _, _) ->
(get, {_Url, _Opts}, _, _, _) ->
{ok, {{Vsn, 200, <<"OK">>}, [{"etag", ?good_etag}], PkgContents}}
end),
[{cache_root, CacheRoot},

Loading…
取消
儲存