Factor Documentation
|
Home
|
Glossary
|
Search
factorcode.org
GET requests with the HTTP client
HTTP client
Next:
POST requests with the HTTP client
Basic usage involves passing a
url
and getting a
response
and data back:
http-get
( url -- response data )
Utilities to retrieve a
url
and save the contents to a file:
download
( url -- )
download-to
( url file -- )
Advanced usage involves constructing a
request
, which allows
HTTP cookies
and
HTTP headers
to be set:
<get-request>
( url -- request )
http-request
( request -- response data )
The
http-get
and
http-request
words output sequences. This is undesirable if the response data may be large. Another pair of words take a quotation instead, and pass the quotation chunks of data incrementally:
with-http-get
( url quot -- response )
with-http-request
( request quot -- response )