how can I make an HTTP request and get both the response content and the response headers?
Asked
Active
Viewed 1,642 times
4 Answers
7
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.

martineg
- 1,269
- 13
- 14
3
Probably the easiest is if you load WebClient
from http://www.squeaksource.com/WebClient.

Lukas Renggli
- 8,754
- 23
- 46
-
1WebClient has actual, useful documentation too! – Frank Shearar Aug 23 '10 at 07:45
1
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.

Frank Shearar
- 17,012
- 8
- 67
- 94