Closed flrgh closed 3 months ago
We need a more real example of how you use the HTTP header. The current seems useless.
@zhuizhuhaomeng the benefit is being able to read the response headers (not just the status line) from the server, which are often relevant to the client in further handling the WebSocket connection:
local ok, err, res = client:connect(...)
assert(ok, err)
local header = assert(res:match("X%-My%-Custom%-Header: (.-)[\r\n]"))
print("value of `X-My-Custom-Header` is " .. header)
For instance, when using this library to implement a WebSocket proxy, it is necessary to consume the response headers so that they can be forwarded to downstream clients.
In 725dfd83a784aba14d25a515dfa12bdeee048913 I have updated the test to make this use case more apparent.
This allows callers of
client:connect()
to retrieve/consume the response status and headers.