Skip to content

Conversation

@un-def
Copy link

@un-def un-def commented Jun 12, 2020

This patch adds two new arguments to the new method:

  • a socket object
  • a boundary, either a plain boundary value or a content-type header value (in the latter case the boundary value will be parsed from the header value)

For example, the cosocket object can be already instantiated for some reason. In this case the library cannot be used now because the second ngx.req.socket() call inside the library returns an error (request body already exists). If one could pass the cosocket object the the new method, the problem would be solved.

Another interesting feature of use an externally created socket object is that it doesn't have to be a real cosocket object. It can be any object with compatible interface. There is an example of how to process form-data with chunked transfer encoding: https://github.com/un-def/lua-buffet/tree/master/examples/resty-chunked-formdata It uses a socket-like object from my library instead of the real cosocket object.

The changes are backward–compatible. When the argument is not provided (or nil), the library still gets the value using corresponding ngx.* API call. When both arguments are provided, the library doesn't use ngx.* API at all.

@un-def
Copy link
Author

un-def commented Jun 12, 2020

The CI build failed with the following error:

nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found

Not totally sure but it seems unrelated to the changes introduced in the PR. All tests are passed locally with openresty/1.15.8.3 on Ubuntu 20.04 x64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant