-
Notifications
You must be signed in to change notification settings - Fork 2k
New feature: extra_headers argument for ngx.location.capture #139
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
base: master
Are you sure you want to change the base?
Conversation
thank you for the patch! just some quick suggestions:
Thanks! |
+1 for the concept, FWIW. |
Thanks for the prompt reply guys! I've not figured out yet how to run tests. I think I missing something in the test environment configuration. Maybe you can help me to set it up, please look at the errors below:
|
Building nginx with debug option, solved this issue. |
I think I've fulfilled all requests, please feel free to review and hopefully merge new feature with your codebase :) |
Hello! On Sat, Jul 14, 2012 at 1:55 PM, vadim-pavlov
I'll try merging your patches in the next week :) Thanks for your contribution! Best regards, |
…ould now be safe to use for sub-requests to application backend server. New tests added. (fixed vars: request_method, content_type, http_referer, http_host, http_user_agent, http_cookie)
Hi! I encountered an issue with request_method variable in the sub-request. Nginx takes a value for it from r->main structure, which I believe not the best choice for us. So I added a fix for this problem in the separate function – ngx_http_lua_subrequest_fix_request_method_variable. This fix helps a lot when you make a request directly to application server like fastcgi, uwsgi, etc, as they hardly relies on this variable when forming a request. Same problem when we overwrite http headers using new 'extra_headers' argument -- corresponding variables in the sub-request should be also updated. In order to achieve this goal I implemented a mapping between these special headers and handlers which updates related fields of the request structure when you set a new header using an extra_header arguments. To cover new cases I've implemented about 10 extra tests. Your test are also works well with these fixes. I hope I didn't add to much complexity, and merging would not take much time. Thank you for making my life easier with killer features of ngx_lua :) Regards, |
One quick question: is it better to rename "extra_headers" to "headers"? do you really want to "add" headers to the parent request's headers? |
I think it would be reasonable to rename this argument to a short form 'headers' because it allows to overwrite headers inherited from the sub-request as well as set new headers. I can rename it if you wish. But we should keep the default behaviour of this function to inherit properties of the parent request and keep parent headers until these headers are explicitly overwritten in 'headers' argument. |
Hello! Sorry for the delay! I've been extremely busy at $work over the last week :) On Mon, Jul 16, 2012 at 8:26 PM, vadim-pavlov
The standard $request_method variable always evaluates to the main I introduced the $echo_request_method in the ngx_echo module that
I think you should use this variable in the subrequest locations Please remove the ngx_http_lua_subrequest_fix_request_method_variable Thanks! |
Hi, guys, |
@SurFire91 Not yet though it's been on my TODO list. BTW, there exists work-arounds:
Because of the existence of these work-arounds, the priority of this PR has been relatively low. But still I'd like to see this to get reviewed and eventually merged. |
@agentzh Thanks for reply. |
@SurFire91 Yeah, I know :) |
e7ac10c
to
cfd4f90
Compare
It'd be great to see this feature merged - the workaround seems clumsy especially for use cases such as making an upstream json POST: Thanks |
So, this feature is not merged yet? I meet the same question. |
Yeah, I agree this is useful though we're really moving to cosockets these years. I don't mind merging a modified and rebased version of this PR if it does not slow down existing user code. @thibaultcha Will be interested in reviewing and possibly taking over this one? |
Hi, Is this feature available now ? Would be of great help |
Would still be useful in 2020 :) |
This pull request is now in conflict :( |
f924579
to
fef2581
Compare
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
Hello, this feature allows to set custom http headers for sub request using an 'extra_headers' argument.
I would appreciate it if you could run tests and merge this feature with your branch :)