最初未设置代理,并且显示为未定义:
httpc:get_options(all).
{ok,[{proxy,{undefined,[]}},
{https_proxy,{undefined,[]}},
{pipeline_timeout,0},
{max_pipeline_length,2},
{max_keep_alive_length,5},
{keep_alive_timeout,120000},
{max_sessions,2},
{cookies,disabled},
{verbose,false},
{ipfamily,inet},
{ip,default},
{port,default},
{socket_opts,[]},
{unix_socket,undefined}]}
我可以毫无问题地设置代理选项:
httpc:set_options([{proxy, {{"www-proxy.mycompany.com", 8000},["localhost"]}}]).
如何在不需要代理时将其恢复为未定义(或没有代理)的状态?我尝试过:
httpc:set_options([{proxy,{undefined, []}}]).
But it throws an exception:
** exception throw: {error,{bad_option,proxy,{undefined,[]}}}
in function httpc:bad_option/2 (httpc.erl, line 1102)
in call from httpc:validate_options/2 (httpc.erl, line 932)
in call from httpc:validate_options/1 (httpc.erl, line 922)
in call from httpc:set_options/2 (httpc.erl, line 236)
我在做什么错了?
答案 0 :(得分:2)
您做错的是传递给函数的参数格式。正确的格式是
OTHER_HOME="$(
[[ "$(
getent \
passwd \
"${OTHER_USER}"
)" =~ ([^:]*:){5}([^:]+) ]] \
&& echo "${BASH_REMATCH[2]}"
)"
现在代理主机将为“”:0。但我不知道您的任务是否可以接受。
回复评论: 尝试直接将“代理”选项设置为http_manager而不是杀死他:
httpc:set_options([{proxy, {{"", 0},[]}}]).
查看erlang shell:
httpc_manager:set_options([{proxy,{undefined, []}}],httpc_manager).