inets httpc:用户指南中的客户端示例不起作用
inets httpc: client example in User's Guide not working
我从 inets User's Guide 复制了以下代码:
$ erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.2 (abort with ^G)
1> inets:start().
ok
2> httpc:set_options([{proxy, {{"www-proxy.mycompany.com", 8000}, ["localhost"]}}]).
ok
3> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request("http://www.erlang.org").
* exception error: no match of right hand side value
{error,
{failed_connect,
[{to_address,{"www-proxy.mycompany.com",8000}},
{inet,[inet],etimedout}]}}
我需要有关如何成功完成该请求的建议。
这似乎有效:
$ erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.2 (abort with ^G)
1> inets:start().
ok
2> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request("http://www.erlang.org").
{ok,{{"HTTP/1.1",200,"OK"},
[{"connection","keep-alive"},
{"date","Sun, 25 Feb 2018 13:44:59 GMT"},
{"server","nginx"},
{"vary","Accept-Encoding"},
{"content-length","12816"},
{"content-type","text/html; charset=UTF-8"}],
"<!DOCTYPE html>\n<html>\n <head>\n <title>Erlang Programming Language</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n <meta name=\"description\" content=\"Erlang Programming Language\"/>\n <meta name=\"keywords\" content=\"erlang, functional, programming, fault-tolerant, distributed, multi-platform, portable, software, multi-core, smp, concurrency\"/>\n
用户指南说:
The following calls use the default client profile. Use the proxy
"www-proxy.mycompany.com:8000", except from requests to localhost.
This applies to all the following requests.
这对我来说很有意义:
Maecenas in tincidunt diam. Pellentesque in orci sed dolor vulputate
tincidunt. Etiam malesuada finibus nisi. Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
要停止客户端,我只是这样做:
inets:stop()
?
编辑:我一定已经知道如何停止服务器了,因为我在这段代码中做到了:
我从 inets User's Guide 复制了以下代码:
$ erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.2 (abort with ^G)
1> inets:start().
ok
2> httpc:set_options([{proxy, {{"www-proxy.mycompany.com", 8000}, ["localhost"]}}]).
ok
3> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request("http://www.erlang.org").
* exception error: no match of right hand side value
{error,
{failed_connect,
[{to_address,{"www-proxy.mycompany.com",8000}},
{inet,[inet],etimedout}]}}
我需要有关如何成功完成该请求的建议。
这似乎有效:
$ erl
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.2 (abort with ^G)
1> inets:start().
ok
2> {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request("http://www.erlang.org").
{ok,{{"HTTP/1.1",200,"OK"},
[{"connection","keep-alive"},
{"date","Sun, 25 Feb 2018 13:44:59 GMT"},
{"server","nginx"},
{"vary","Accept-Encoding"},
{"content-length","12816"},
{"content-type","text/html; charset=UTF-8"}],
"<!DOCTYPE html>\n<html>\n <head>\n <title>Erlang Programming Language</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n <meta name=\"description\" content=\"Erlang Programming Language\"/>\n <meta name=\"keywords\" content=\"erlang, functional, programming, fault-tolerant, distributed, multi-platform, portable, software, multi-core, smp, concurrency\"/>\n
用户指南说:
The following calls use the default client profile. Use the proxy "www-proxy.mycompany.com:8000", except from requests to localhost. This applies to all the following requests.
这对我来说很有意义:
Maecenas in tincidunt diam. Pellentesque in orci sed dolor vulputate tincidunt. Etiam malesuada finibus nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
要停止客户端,我只是这样做:
inets:stop()
?
编辑:我一定已经知道如何停止服务器了,因为我在这段代码中做到了: