aardio 文档

aardio 范例: Cookies/inet.whttp

请参考 inet.setCookie

import console;
import inet.whttp;
var http = inet.whttp(); 

//写入新的 Cookie
http.get("https://httpbin.org/cookies/set/newName/newValue");

// 添加 Cookie 方式 1,指定 Cookie 对象纯数组(必须用 [] 创建数组)
http.extraCookies = [
    {
        name = "user_token";
        value = "aardio_test_123";
    }
];

// 添加 Cookie 方式 2,直接传包含名值对的表
http.extraCookies = {
    user_token = "aardio_test_123";
    user_token2 = "aardio_test_456";
};

// 添加 Cookie 方式3,等号前后不要放空格,分号一个空格,不要做 URL 编码
http.extraCookies = "user_token=aardio_test_123; user_token2=aardio_test_456"

// 发送 GET 请求,httpbin.org/cookies 接口会回显客户端发送的所有 Cookie
var result,err = http.get("https://httpbin.org/cookies/set/newName/newValue");

//显示结果
console.status(result,"Cookies:",result,err)

/*
inet.whttp 自动管理会话 Cookie ,默认不支持持久 Cookie。
inet.whttp 使用隔离会话,不会共享,也不会与 inet.http,web.rest,web.form 等共享会话。
默认只能使用 extraCookies 添加 Cookie ,不能直接替换。

inet.http 与 inet.whttp 都可以调用 disableCookies 禁用自动管理 Cookie 的功能。
*/
//请参考 inet.setCookie: https://www.aardio.com/zh-cn/docs/examples/Network/inet/http/cookies.http.html
console.pause(); 
Markdown 格式