如何使用REBOL发送带有自定义标头的HTTP帖子 [英] How to send an HTTP post with a custom header using REBOL

查看:157
本文介绍了如何使用REBOL发送带有自定义标头的HTTP帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用网站的API访问REBOL网站,但我遇到了问题。 API调用需要XML格式的自定义标头和请求。我一直在尝试使用read / custom,但我不确定如何包含标题,或者应该采用什么格式。 system / options / cgi中的默认头是一个对象,所以我认为它应该是一个对象,但你会把它放在哪里? (添加到system / options / cgi没有用。)

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]

虽然没有把http-custom-header放在任何有用的位置,但这不起作用。

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

我走在正确的轨道上吗?如果是这样,标题应该放在哪里?否则,使用REBOL发送HTML标头和请求的可行方法是什么?

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?

推荐答案

我已经弄明白了。您只需将标题和块(不是对象)添加到读取/自定义块。因此......

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
]

这篇关于如何使用REBOL发送带有自定义标头的HTTP帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆