Executing an HTTP request in Pharo and receiving response headers

How can I make an HTTP request and get both the response content and the response headers?

+3
source share
4 answers

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.
+5
source

Probably the easiest way is if you download WebClientfrom http://www.squeaksource.com/WebClient .

+3
source

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.
+1
0

Source: https://habr.com/ru/post/1761029/


All Articles