HttpQuery-options

此JSON结构用于配置HttpQuery函数和HttpQuery_Go函数发送HTTP请求的各项参数。

HTTP请求方法,例如:GETPOST等。 method string 请求体内容。例如在POST请求中,body可以包含表单数据、JSON数据、文本等。 body string 字符集编码。用于指定请求体中文本数据的编码方式,例如:"UTF-8"。 charset string Cookie是用于在客户端(通常是浏览器)和服务器之间存储和交换状态信息的小型数据片段。 cookie string 调试模式开关。设置为true时,HttpQuery函数调用将返回完整的HTTP响应报文;设置为false时仅返回响应报文Body中的数据。 debug bool HTTP请求头信息,以键值对形式存在(JSON结构),用于传递各种信息,如内容类型、认证信息、缓存控制等。 headers JSON 超时时间设置,单位为毫秒。设置1000表示1秒钟超时。 timeout number

使用范例:

function main() {
    var options = {
        method: "POST",
        body: "a=10&b=20&c=30",
        charset: "UTF-8",
        cookie: "session_id=12345; lang=en",
        debug: false,
        headers: {"TEST-HTTP-QUERY": "123"},
        timeout: 1000
    }
    var ret = HttpQuery("http://127.0.0.1:8080", options)
    Log(ret)
}

以上代码执行时发出的HTTP报文:

POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: session_id=12345; lang=en
Host: 127.0.0.1:8080
Test-Http-Query: 123
Transfer-Encoding: chunked
User-Agent: Mozilla/5.0 (Macintosh; ...
Accept-Encoding: gzip, deflate, br

e
a=10&b=20&c=30
0

{@fun/Global/HttpQuery HttpQuery}, {@fun/Global/HttpQuery_Go HttpQuery_Go}