如何发起HTTP请求并获取响应内容和响应头?
或者使用新的Zinc框架,就像这样:
| response content headers |
response := ZnClient new
url: 'http://stackoverflow.com';
get;
response.
content := response contents.
headers := response headers.
可能最简单的方法是从http://www.squeaksource.com/WebClient加载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.