Skip to content

Add abbility to change HTTP reply code from LUA procedure. #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amdei opened this issue Feb 6, 2017 · 4 comments
Closed

Add abbility to change HTTP reply code from LUA procedure. #74

amdei opened this issue Feb 6, 2017 · 4 comments
Labels
enhancement help wanted Extra attention is needed

Comments

@amdei
Copy link

amdei commented Feb 6, 2017

It would be quite nice to have abbility to send arbitrary HTTP reply code from within called LUA procedure.

In particular, it will make possible to utilize http://nginx.org/en/docs/http/ngx_http_auth_request_module.html for access control, based on result of LUA function invocation.

AFAICS, we could control only reply body so far.
If this feature already available, would be good to see example in readme.

@dedok
Copy link
Contributor

dedok commented Feb 6, 2017

This feature does not exist. Basically it is hard to implement due to Tarantool binary protocol limitations and nginx upstream phases synchronisation.

So I thought about this feature a lot and I have the only one idea. if I share it with you can you implement it? :)

P.S. This feature does not have high priority at the moment.

@dedok dedok added enhancement help wanted Extra attention is needed labels Feb 6, 2017
@amdei
Copy link
Author

amdei commented Feb 7, 2017

if I share it with you can you implement it?

Will do my best!

@dedok
Copy link
Contributor

dedok commented Feb 14, 2017

The first part is

Before we go any further you have to read this one:

Tarantool iproto: https://tarantool.org/doc/dev_guide/internals_index.html

So there are have few problems:

  1. Tarantool does not produce headers or stutes in own headers, information passed via body.
    That is a pain, because nginx has phases handlers. For instance nginx sends http headers and status right after process_headers, but Tarantool may not return full body in this stage due to may reasons. (src/ngx_http_tnt_handlers.c:972)

  2. Tarantool has greeting, which needs sync with phases handlers.

  3. Tarantool's response may return in many buffers due to network issues and configuration.

Possible implementation is:
Tarantool protocol does not good for classical STATUS HEADERS BODY.

How could it be fixed?

Well. All problems could be solved by re-implement nginx socket handlers (i.e. write/read to upstream write/read from upstream). - nginx gives such feature.

In detail it will be like - The new Nginx write handler should wait all body at the header phase. After it happened (means all body recived) parser should try to find information about status and headers in body and if it found (means status and header) it should send status and headers to the client.

Or you can hack nginx's phases.

dedok added a commit that referenced this issue Jun 18, 2017
…l 1.6.x, it starts from this commit. Update tests & add some new
@dedok
Copy link
Contributor

dedok commented Jun 18, 2017

@dedok dedok closed this as completed Jun 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants