Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send HTTP POST requests using only Rebol3

What is the simplest way of sending HTTP POST requests and getting response (in XML format for example) using only Rebol3?

Is there an equivalent of using read/custom in Rebol2, as it is done in this question?

How to send an HTTP post with a custom header using REBOL

And where should I be donwnloading my Rebol3 binaries from? I've not found a lot of documentation on that...

like image 636
dreamyToto Avatar asked Oct 04 '13 13:10

dreamyToto


1 Answers

The documentation at on Ports: Synchronous and Asynchronous Operations shows how to use both GET and POST. To summarize:

The default behavior is to assume the post data should be considered as application/x-www-form-urlencoded. (If you want to encode a block of ordinary Rebol data into that format, see %altwebform.r)

result: write http://www.rebol.com/cgi-bin/updata.r data 

If you need a custom header, then instead of passing a string you need to pass a block. Start it with the WORD! post followed by a block of Rebol-formatted key/value pairs, and then your data:

result: write http://www.rebol.com/cgi-bin/updata.r compose [
    post [
        Content-type: "text/x-rebol"
        ;-- other fields here
    ]
    (data)
]

The result will be in binary! and can be converted to string! to parse out any XML or whatever.

where should I be downloading my Rebol3 binaries from?

You should download binaries from http://www.rebolsource.net/

like image 124
Graham Chiu Avatar answered Sep 27 '22 22:09

Graham Chiu