Welcome! Log In Create A New Profile

Advanced

Re: NJS Questions and/or Bugs

Lance Dockins
August 12, 2021 08:40AM
Thank you Dmitry.  This helps a ton. I will note that the post key/value pair solution only works for URL encoded post values.  If the enctype is set to multipart/form-data, you get get the data without writing your own data parser.  I already wrote one for URL encoded types and was working on one for multipart form data at the time that I wrote this.  Parsing the data with JS is just not the most elegant solution - particularly since some sort of parsing is going on already.  Maybe I am also just spoiled from using fastcgi to PHP where all of that is pre-parsed.   But it seems like a fairly straightforward request data access feature.  I guess I will just have to make due for now.


--
Lance Dockins
On Aug 12, 2021, 1:14 AM -0500, Dmitry Volyntsev <xeioex@nginx.com>, wrote:
> Hi Lance,
>
> Thanks for your detailed feedback.
>
> > What exactly should r.variables and r.rawVariables contain?  ....
>
> r.variables and r.rawVariables are special objects, because they are
> created on the fly. There is no way to get all the possible variable
> names from nginx. So Object.keys(r.variables) is empty list. Therefore
> dumping and iterating over r.variables returns nothing. But, if you have
> a $foo variable, r.variables.foo would return the $foo content as a string.
>
> > That might also be a fallacy of our testing methodology since we’re
> using JSON.stringify to visualize the output in the browser.
>
> The JSON.stringify() is no the best, use njs.dump().
> http://nginx.org/en/docs/njs/reference.html#njs
>
> > Is there already an NJS object or are there plans for an object that
> parses and maps POST key/value pairs into a JSON object?
>
> Take a look at https://github.com/nginx/njs/issues/48#issuecomment-415745451
>
> > Filters for the different phase of the Nginx request
>
> We are thinking about the adding phases handlers.
>
> > Direct variable access to the Nginx variables (either read only or
> writable depending on the context within which they were created)
>
> this is already in place
>
> > Array like access to the request arguments (e.g. cookies, post args,
> query string args, etc).  Right now the only version of this that we’ve
> found reliably working in the js_content phase is query string related
> stuff (in the args array)
>
> Feel free to add a feature request here https://github.com/nginx/njs
> Although this is not a feature requested often (for some reason).
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

NJS Questions and/or Bugs

Lance Dockins August 11, 2021 08:44PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 09:52PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:06PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:22PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:32PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:40PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:44PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:50PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:58PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 11:02PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 11:46PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 11:52PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:42PM

Re: NJS Questions and/or Bugs

Dmitry Volyntsev August 12, 2021 02:16AM

Re: NJS Questions and/or Bugs

Lance Dockins August 12, 2021 08:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready