簡體   English   中英

在Pharo中發出HTTP請求並獲取響應頭

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM