ItGo.me Focus on IT Recommend

Home > xml - How to send an HTTP post with a custom header using REBOL

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

I've been trying to access a site with REBOL using the site's API, but I'm having problems. The API call expects a custom header and a request in XML format. I've been trying with read/custom, but I'm unsure how to include the header, or what format it should take. The default header in system/options/cgi is an object, so I assume it should be an object, but where would you put it? (Adding to system/options/cgi hasn't worked.)

I'm guessing the code below is something like what I need...

http-custom-header: make object! [
    Content-Type: text/xml
    etc...
]

xml-request: {
    <?xml version="1.0" encoding="utf-8"?>
    <etc>etc...<etc>
}

site-URL: http://etc...

response: read/custom site-URL reduce ['post xml-request]

That won't work though as http-custom-header hasn't been put anywhere useful.

Am I on the right track? If so, where should the header go? Otherwise, what's a workable way to send an HTML header and request using REBOL?

Recommend:http headers - How to send custom http_headers for RPC calls using python xmlrpclib

special custom http_headers at the time of calling RPC methods. python http-headers xml-rpc xmlrpclib
  |
  this question edited Jul 10 '13 at 10:57 sorin 53.7k 78 280 448 asked Jan 7 '11 at 9:27 shahjapan 5,452 13 48 86 add a co

answer 1

I've figured it out. You just add 'header and a block (not an object) to the read/custom block. Thus...

http-custom-header: [
    Content-Type: text/xml
    etc...
]

xml-request: {
    <?xml version="1.0" encoding="utf-8"?>
    <etc>etc...<etc>
}

site-URL: http://etc...

response: read/custom site-URL reduce [
    'header http-custom-header
    'post xml-request
]

Recommend:How to get the HTTP response headers in Rebol3

binary response or an error. So in the "one-off" style of doing a GET or a POST there is nowhere to get the response headers from. result: read http://www.rebol.com In this post about how to do it in Rebol2, it suggests you have to open a

oriUlr:http://stackoverflow.com/questions/8691754/how-to-send-an-http-post-with-a-custom-header-using-rebol

------splitte line----------------------------