Giter Site home page Giter Site logo

Comments (8)

agentzh avatar agentzh commented on September 23, 2024

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.

 avatar commented on September 23, 2024

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.

agentzh avatar agentzh commented on September 23, 2024

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.

igrigorik avatar igrigorik commented on September 23, 2024

+1 for merging this - was looking for exactly the same functionality earlier on Saturday.

from lua-nginx-module.

calio avatar calio commented on September 23, 2024

Will do it tomorrow or so :)

from lua-nginx-module.

agentzh avatar agentzh commented on September 23, 2024

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.

 avatar commented on September 23, 2024

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.

agentzh avatar agentzh commented on September 23, 2024

Already added you to ngx_lua's member list; please check if it works for you ;)

from lua-nginx-module.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.