Send HTTP Requests with READ and WRITE - qtxie/red GitHub Wiki
Send HTTP Requests with READ and WRITE
READ and WRITE can be used to send HTTP requests.
The default behavior for WRITE is to assume the post data should be considered as application/x-www-form-urlencoded
, this can be changed by setting the http headers.
Spec
read | write url [
POST | PUT | GET ;-- http method: POST, PUT and GET (word!)
headers [ ;-- (optional) http header fields (block!)
name: value ;-- name (any-word!), value (any-string!)
...
]
options [ ;-- (optional) http request options (block!)
redirect?: true | false ;-- TRUE by default
timeout: value ;-- set timeout: value (integer!)
]
data ;-- (optional) data to be sent (string! binary!)
]
Examples
read http://httpbin.org/get ;-- GET request
read http://httpbin.org/get [ ;-- GET request with custom headers
GET
headers [
Content-type: "text/x-x"
Header-Test: "abc"
]
]
write http://httpbin.org/post #{abcd1234} ;-- POST request
write http://httpbin.org/post [POST #{abcd1234}] ;-- same as the write command above
write http://httpbin.org/post [
POST
headers [
Content-type: "text/x-x"
Header-Test: "abc"
]
options [
redirect?: no
]
"test 123"
]