6

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

4

4 回答 4

7

或者使用新的Zinc 框架,例如:

| response content headers |

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

content := response contents.
headers := response headers.
于 2012-02-01T23:47:44.577 回答
3

可能最简单的方法是WebClienthttp://www.squeaksource.com/WebClient加载。

于 2010-08-23T06:05:08.357 回答
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.
于 2010-08-26T12:38:23.347 回答
0

或者如果你想用它们做更多的事情,海边的一键式图像用于pharosqueak

于 2010-08-24T19:10:41.127 回答