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

时间:2010-08-22 23:44:45

标签: http smalltalk squeak pharo

如何发出HTTP请求并同时获取响应内容和响应标头?

4 个答案:

答案 0 :(得分:6)

或者使用新的Zinc framework,例如:

| response content headers |

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

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

答案 1 :(得分:3)

如果您从http://www.squeaksource.com/WebClient加载WebClient,可能最简单。

答案 2 :(得分: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.

答案 3 :(得分:0)

或者,如果您想对他们进行更多操作,可以使用pharosqueak的海边一键式图片