外观
http 模块
本页根据当前原生参数检查、Lua 包装层和返回栈核验。源码核验不代表目标设备已验收。
[参数] 表示可选参数;... 仅用于实现确实接收可变参数的接口。重载分别列出。
模块加载:local http = require("http")
http.head
lua
http.head(url [, timeoutSeconds, headers])发起 HEAD 请求 (http.head)。 源码契约:timeoutSeconds 默认 10;网络失败可返回 nil 状态和 nil 响应头。
返回:statusCode, headersJson。
核对依据:ext/layout/usr/local/monkeyking/lib/http.lua:16;状态:签名已按源码复核,真机待验证。
http.get
lua
http.get(url [, timeoutSeconds, headers])同步 GET,默认超时 10 秒;不支持旧文档第四个 no_escape 参数,不保证协程让出。 源码契约:timeoutSeconds 默认 10;网络失败可返回 nil 状态和 nil 响应头。
返回:statusCode, headersJson, body。
核对依据:ext/layout/usr/local/monkeyking/lib/http.lua:35;状态:签名已按源码复核,真机待验证。
http.delete
lua
http.delete(url [, timeoutSeconds, headers])发起 DELETE 请求 (http.delete)。 源码契约:timeoutSeconds 默认 10;网络失败可返回 nil 状态和 nil 响应头。
返回:statusCode, headersJson, body。
核对依据:ext/layout/usr/local/monkeyking/lib/http.lua:55;状态:签名已按源码复核,真机待验证。
http.post
lua
http.post(url [, timeoutSeconds, headers, body])同步 POST;请求体为字符串,请求头支持表或 JSON 文本。 源码契约:timeoutSeconds 默认 10;headers 可为 table 或 JSON string。
返回:statusCode, headersJson, body。
核对依据:ext/layout/usr/local/monkeyking/lib/http.lua:75;状态:签名已按源码复核,真机待验证。
http.put
lua
http.put(url [, timeoutSeconds, headers, body])发起 PUT 请求 (http.put)。 源码契约:timeoutSeconds 默认 10;headers 为 table。
返回:statusCode, headersJson, body。
核对依据:ext/layout/usr/local/monkeyking/lib/http.lua:105;状态:签名已按源码复核,真机待验证。
http.download
lua
http.download(url, outputPath [, timeoutSeconds, resume, callback, blockSize])HTTP 文件下载 (http.download)。 源码契约:默认 timeoutSeconds=10、resume=false、blockSize=8192;会写入 outputPath。
返回:true, statistics | false, statusCode。
核对依据:ext/layout/usr/local/monkeyking/lib/http.lua:251;状态:签名已按源码复核,真机待验证。
