在Pharo中发起HTTP请求并获取响应头

6

如何发起HTTP请求并获取响应内容和响应头?

4个回答

7

或者使用新的Zinc框架,就像这样:

| response content headers |

response := ZnClient new 
    url: 'http://stackoverflow.com';
    get;
    response.

content := response contents.
headers := response headers.

3

1
WebClient也有实际、有用的文档! - Frank Shearar

1
安装WebClient:
(Installer ss project: 'WebClient')
  install: 'WebClient-Core'

然后

response := WebClient httpGet: 'http://www.google.com/'.
headers := response headers. "An OrderedCollection of headername -> headervalue"
body := response content.

0

或者如果你想对它们进行更多操作,可以下载PharoSqueak这个海边一键式镜像


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接