跳到主要内容

Response:getHeader()

按名称读取一个响应头。

签名​

getHeader(name: string): string

参数​

参数类型描述
namestring请求头名称,不区分大小写

返回值

string - 请求头的值;响应中不包含该请求头时返回 nil。

示例​

local response = Request("https://api.example.com/data"):get()
local type = response:getHeader("Content-Type")
toast("Server sent " .. (type or "no content type"))

兼容版本:1.0.0.37 及以上