Comments (8)
Well, we should borrow the implementation of ngx_headers_more's more_set_input_headers and more_clear_input_headers directives here ;) Your patch here is indeed just the first-order approximation :)
I'm wondering why __index and __newindex did not work for you; can you elaborate? Or could you just publish a temporary branch for me to investigate?
The ngx.req_header_get() and ngx.req_header_set() functions have an inconsistent style with other APIs like ngx.var.FOO and ngx.header.BAR and I don't think I'll accept them as part of the API ;)
Anyway, I'll look into this myself in the next few days ;) Thank you all the same :)
from lua-nginx-module.
yay, long ago, but i have found time to dig deeper into this thing. i am able to generate a table which has all the needed methods.
getting elements via ngx.req_header["X"] and setting them via ngx.req_header["X"]="foo . Getting ALL headers works, too but for now with ngx.req_header() with the __call metamethod... i think there is nothing else i can use in lua at the moment. In lua5.2 there would be __pairs and __ipairs available but i'm stuck with 5.1 here (i think we talked about that in irc some time ago)
Removing headers can be done with ngx.req_header["X"] = nil ... but this is a very, very dirty hack realized with memmove and i think there are a lot of unknown disadvantages with that (i won't imagine ;-) )
The more-headers-module uses the nginx-scripting-engine which handles the complex-values generated by the module? Don't know if i would do it correct, if i try to implement something based on this.
Here is the current branch of my fork:
https://github.com/moodydeath/lua-nginx-module/tree/req_header
from lua-nginx-module.
On Wed, Apr 27, 2011 at 6:07 PM, moodydeath
[email protected]
wrote:
yay, long ago, but i have found time to dig deeper into this thing. i am able to generate a table which has all the needed methods.
getting elements via ngx.req_header["X"] and setting them via ngx.req_header["X"]="foo . Getting ALL headers works, too but for now with ngx.req_header() with the __call metamethod... i think there is nothing else i can use in lua at the moment. In lua5.2 there would be __pairs and __ipairs available but i'm stuck with 5.1 here (i think we talked about that in irc some time ago)Removing headers can be done with ngx.req_header["X"] = nil ... but this is a very, very dirty hack realized with memmove and i think there are a lot of unknown disadvantages with that (i won't imagine ;-) )
The more-headers-module uses the nginx-scripting-engine which handles the complex-values generated by the module? Don't know if i would do it correct, if i try to implement something based on this.
Here is the current branch of my fork:
https://github.com/moodydeath/lua-nginx-module/tree/req_header
Thanks for your hard work. I'm on vacation now and I'll look into this
in a few days.
Thanks!
-agentzh
from lua-nginx-module.
+1 for merging this - was looking for exactly the same functionality earlier on Saturday.
from lua-nginx-module.
Will do it tomorrow or so :)
from lua-nginx-module.
On Wed, Apr 27, 2011 at 6:07 PM, moodydeath
[email protected]
wrote:
yay, long ago, but i have found time to dig deeper into this thing. i am able to generate a table which has all the needed methods.
getting elements via ngx.req_header["X"] and setting them via ngx.req_header["X"]="foo . Getting ALL headers works, too but for now with ngx.req_header() with the __call metamethod... i think there is nothing else i can use in lua at the moment. In lua5.2 there would be __pairs and __ipairs available but i'm stuck with 5.1 here (i think we talked about that in irc some time ago)
I've merged a modified version of your patches into ngx_lua's master
branch just now.
I've changed my mind by introducing explicit Lua methods like
ngx.req.set_header(), ngx.req.clear_header(), and
ngx.req.get_headers(). And there's no ngx.req_header nor
ngx.req.header table now.
Under the hook, ngx.req.clear_header(name) is implemented by
ngx.req.set_header(name, nil).
Removing headers can be done with ngx.req_header["X"] = nil ... but this is a very, very dirty hack realized with memmove and i think there are a lot of unknown disadvantages with that (i won't imagine ;-) )
Well, I simply copied the related stuffs from ngx_headers_more and fixed this :)
The more-headers-module uses the nginx-scripting-engine which handles the complex-values generated by the module? Don't know if i would do it correct, if i try to implement something based on this.
As I've said on IRC, the scripting engine stuff is unrelated here :)
Here is the current branch of my fork:
https://github.com/moodydeath/lua-nginx-module/tree/req_header
I didn't merge your fork directly. Rather, I rewrite your patch from
scratch by looking at your patches. Thank you very much!
Can we send you a commit bit to the official ngx_lua repos such that
you can create branches directly there?
Thank you for your contribution!
-agentzh
from lua-nginx-module.
Hi, thanks for your awesome work! I'm happy, if my code was helpful in some ways :-)
It would be great to be able to have a branch at the official repo when implementing new things. ("ould make my life even easier, because i would not have to maintain two repositories and keep them in sync for my projects)
Thanks,
moodydeath
from lua-nginx-module.
Already added you to ngx_lua's member list; please check if it works for you ;)
from lua-nginx-module.
Related Issues (20)
- ngx.say not work
- init_by_lua during Nginx config test HOT 3
- Using outer scope required modules inside an ngx.timer.at handler HOT 4
- when header_filter_by_lua_file run failed. HOT 1
- OpenResty keepalive connection appears to be hung HOT 6
- unexpected phase error when `ngx.send_header()` trigger `if_unmodified` 412 logic HOT 2
- nginx: [emerg] dlopen() "/etc/nginx/ngx_http_naxsi_module.so" failed (/etc/nginx/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 nginx: configuration file /etc/nginx/nginx.conf test failed
- nginx: [emerg] dlopen() "/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so" failed (/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 HOT 2
- Nginx + LibreSSL (undefined symbol: SSL_client_hello_get0_ext) HOT 3
- Possible to support `tcpsock:receive` in `balancer_by_lua` context?
- `ngx.req.set_body_data` API does not work in `balancer_by_lua` phase HOT 1
- errlog get_logs doesnt get error logs in privileged agent and visa versa HOT 3
- Core dumps with Lua nginx module and OCSP enabled on ingress-nginx HOT 2
- attempt to redefine .. in cdef HOT 1
- New module release HOT 2
- bug: memory leak when collecting response body chunks HOT 1
- ngx_http_lua_module 0.10.27 HOT 12
- Cannot remove headers set with add_header and variable value from map in http block HOT 2
- unreachable code in ngx_http_lua_util HOT 1
- possible multiple redundant comparison of functions return codes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-nginx-module.