feature: add timer context support for get_client_body_reader.#336
feature: add timer context support for get_client_body_reader.#336zhuizhuhaomeng wants to merge 1 commit into
Conversation
|
@zhuizhuhaomeng Would you mind adding a proper description why this is needed, develop a test for this, and to rebase this on top of latest master branch so that tests are run again? TIA |
f362b64 to
a689e61
Compare
sriemer
left a comment
There was a problem hiding this comment.
Please provide more context here for which use cases this feature is required.
Consider reading body value in 1 byte chunks in the test to demo reading chunks of data. TIA
So is the use case here something like reading big files or video chunks?
| -- ngx.req.socket() / ngx.req.get_headers() do not work here. | ||
| local httpc = require("resty.http").new() | ||
| local headers = { ["Content-Length"] = content_length } | ||
| local reader, err = httpc:get_client_body_reader(8192, sock, headers) |
There was a problem hiding this comment.
I like this even more if reducing the buffer size to 1 byte for fun so that it really becomes visible that the loop below to read and concat buffer is called 4 times for
f
o
o
nil
Add a comment
-- inefficient buffer of 1 byte to show reading body value in multiple chunks
| local reader, err = httpc:get_client_body_reader(8192, sock, headers) | |
| -- inefficient buffer of 1 byte to show reading body value in multiple chunks | |
| local reader, err = httpc:get_client_body_reader(1, sock, headers) |
There was a problem hiding this comment.
Tested against 2 bytes buffer as well. Works. 😃
No description provided.