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