如何发出HTTP请求并同时获取响应内容和响应标头?
答案 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)