[英]Making an HTTP request in Pharo and getting the response headers
如何發出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
,可能最簡單的方法。
要安裝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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.