在 lua 中获得 network.request 响应 headers

Get network.request response headers in lua

我正在使用 network.request 这样的:

network.request( fullUrl, "POST", networkListener, params)

并在我的网络侦听器中收到这样的响应:

local function networkListener( event )
    if ( event.isError ) then
        response = {};
    else
        response = json.decode(event.response);
    end
end

我正在接收请求的 body 响应,但 我也想接收请求的响应 headers。我怎样才能做到这一点?

非常感谢!

The documentation for network.request 说:

network.request( url, method, listener [, params] )

listener (required)

Listener. The listener function invoked at various phases of the HTTP operation. This is passed a networkRequest event.

the documentation for networkRequest links to event.responseHeaders,给出了这个例子:

-- Print the Content-Type header value for a response
local function networkListener( event )
    print( "Content-Type of response is: " .. event.responseHeaders["Content-Type"] )
end