开发者

Making an HTTP request in Pharo and getting the response headers

how can I make an HTTP request and get both the respons开发者_运维技巧e content and the response headers?


Or using the new Zinc framework, something like:

| response content headers |

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

content := response contents.
headers := response headers.


Probably the easiest is if you load WebClient from http://www.squeaksource.com/WebClient.


To install WebClient:

(Installer ss project: 'WebClient')
  install: 'WebClient-Core'

and then

response := WebClient httpGet: 'http://www.google.com/'.
headers := response headers. "An OrderedCollection of headername -> headervalue"
body := response content.


Or if you want to do something more with them, the seaside one-click image for pharo or squeak

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜