
Hi all, If I'm sending single valued data over web, eg. a=111, b=222, c=333, then I can do http://.../xxx.cgi?a=111&b=222&c=333 How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I? I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array. -- William Park <opengeometry@yahoo.ca>

Sure, the second way you listed is correct, and the CGI would store each value for that key into an array. In that example, you would end up with a Hash of Arrays. In Perl, that would look like this: %params = ( 'A' => [ 111, 222, 333 ] ); Reference material about CGIs is here: https://metacpan.org/pod/distribution/CGI/lib/CGI.pod#Fetching-the-names-of-... On Sat, May 12, 2018 at 5:48 PM, William Park via talk <talk@gtalug.org> wrote:
Hi all,
If I'm sending single valued data over web, eg. a=111, b=222, c=333, then I can do http://.../xxx.cgi?a=111&b=222&c=333
How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I?
I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array. -- William Park <opengeometry@yahoo.ca> --- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk
-- Alex Beamish Software Developer / https://ca.linkedin.com/in/alex-beamish-5111ba3 Speaker Wrangler, Toronto Perlmongers / http://to.pm.org/ Baritone, Board Member, Toronto Northern Lights, 2013 Champions / www.northernlightschorus.com Certified Contest Administrator, Barbershop Harmony Society / www.barbershop.org

If you are in control of both ends, and have a common environment at both ends (or different env. which have standards of ...), then you can use a de/serialization library as well as encode/decode it to sit on the cgi (get/put...), advantage of this would be hiding, ability to present data that may mess up the url (i.e. =, &, ', ", etc), as well the libraries have your serialization and re-hydration to object all done for you, even for much more complex object then an array. To an extreme, you would pretty much just have to make a encodeToUrl( [object name], [encode method] ); on your formation of url, and MyObjectName myObj(decodeFromUrlArg(["arrayname"], [encode method]); But this could be over-kill for your needs (pulling a lib for this into your current setup). This also assumes reflection based language (java, .net....) or accompanying/annotated meta-data (c++). -tl On Sat, May 12, 2018 at 5:48 PM, William Park via talk <talk@gtalug.org> wrote:
Hi all,
If I'm sending single valued data over web, eg. a=111, b=222, c=333, then I can do http://.../xxx.cgi?a=111&b=222&c=333
How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I?
I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array. -- William Park <opengeometry@yahoo.ca> --- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk

On 2018-05-12 05:48 PM, William Park via talk wrote:
Hi all,
If I'm sending single valued data over web, eg. a=111, b=222, c=333, then I can do http://.../xxx.cgi?a=111&b=222&c=333
How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I?
I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array.
If JSON is an option, it is pretty easy to do what you're after in javascript. For example, I've been working on a project using crypto.subtle in the browser. I generate a key and an IV with javascript, and it is easy to represent the arrays of bytes like you've specified. For example: I have an IV Uint8Array(16) that looks like this: Uint8Array(16) [ 147, 174, 163, 227, 241, 236, 204, 23, 159, 18, … ] As a string it looks like what you'd expect - iv.toString() shows: "147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153" Now what you're after with mapping in JSON (I've inserted line breaks): JSON.stringify(iv)) {"0":147,"1":174,"2":163,"3":227,"4":241,"5":236, "6":204,"7":23,"8":159,"9":18,"10":218, "11":74,"12":177,"13":105,"14":214,"15":153} Alternatively, you can get an unkeyed array using Array.from() and converting that to JSON: JSON.stringify(Array.from(iv)) "[147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153]" Any of that look useful? Cheers, Jamon

On Sat, May 12, 2018 at 08:38:23PM -0400, Jamon Camisso via talk wrote:
On 2018-05-12 05:48 PM, William Park via talk wrote:
Hi all,
If I'm sending single valued data over web, eg. a=111, b=222, c=333, then I can do http://.../xxx.cgi?a=111&b=222&c=333
How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I?
I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array.
If JSON is an option, it is pretty easy to do what you're after in javascript. For example, I've been working on a project using crypto.subtle in the browser. I generate a key and an IV with javascript, and it is easy to represent the arrays of bytes like you've specified.
For example: I have an IV Uint8Array(16) that looks like this: Uint8Array(16) [ 147, 174, 163, 227, 241, 236, 204, 23, 159, 18, ??? ]
As a string it looks like what you'd expect - iv.toString() shows: "147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153"
Now what you're after with mapping in JSON (I've inserted line breaks): JSON.stringify(iv)) {"0":147,"1":174,"2":163,"3":227,"4":241,"5":236, "6":204,"7":23,"8":159,"9":18,"10":218, "11":74,"12":177,"13":105,"14":214,"15":153}
Alternatively, you can get an unkeyed array using Array.from() and converting that to JSON: JSON.stringify(Array.from(iv)) "[147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153]"
Any of that look useful?
What does URL look like, when sending those 16 integers? Or, has Web/CGI evolved to a point where you just include JSON content in POST method, and javascript handles the magic behind the scene? -- William Park <opengeometry@yahoo.ca>

On 2018-05-13 12:57 AM, William Park via talk wrote:
Any of that look useful?
What does URL look like, when sending those 16 integers?
Or, has Web/CGI evolved to a point where you just include JSON content in POST method, and javascript handles the magic behind the scene?
I'm using PUT, but POST would be the same - the URL in my Django application is just a restful endpoint at /save. I don't know how Perl & CGI handle PUT/POST data that isn't a form field or URL parameter, but this link looks useful: https://stackoverflow.com/questions/19610312/perl-cgi-passing-variable-in-po... Cheers, Jamon

On Sun, May 13, 2018 at 12:57:09AM -0400, William Park via talk wrote:
On Sat, May 12, 2018 at 08:38:23PM -0400, Jamon Camisso via talk wrote:
On 2018-05-12 05:48 PM, William Park via talk wrote:
Hi all,
If I'm sending single valued data over web, eg. a=111, b=222, c=333, then I can do http://.../xxx.cgi?a=111&b=222&c=333
How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I?
I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array.
If JSON is an option, it is pretty easy to do what you're after in javascript. For example, I've been working on a project using crypto.subtle in the browser. I generate a key and an IV with javascript, and it is easy to represent the arrays of bytes like you've specified.
For example: I have an IV Uint8Array(16) that looks like this: Uint8Array(16) [ 147, 174, 163, 227, 241, 236, 204, 23, 159, 18, ??? ]
As a string it looks like what you'd expect - iv.toString() shows: "147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153"
Now what you're after with mapping in JSON (I've inserted line breaks): JSON.stringify(iv)) {"0":147,"1":174,"2":163,"3":227,"4":241,"5":236, "6":204,"7":23,"8":159,"9":18,"10":218, "11":74,"12":177,"13":105,"14":214,"15":153}
Alternatively, you can get an unkeyed array using Array.from() and converting that to JSON: JSON.stringify(Array.from(iv)) "[147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153]"
Any of that look useful?
What does URL look like, when sending those 16 integers?
Or, has Web/CGI evolved to a point where you just include JSON content in POST method, and javascript handles the magic behind the scene?
With a lot of people running node.js on the server side, yes that is often the case. Things like php of course handle form submitions with arrays nicely for you. -- Len Sorensen

William Park via talk wrote:
How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI script? I don't think I can do something like http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333 Or, can I?
I have seen a same variable repeated, http://.../xxx.cgi?A=111&A=222&A=333 but that means the CGI script has to build the array.
The square brackets aren't support HTTP characters, they are actually considered unsafe and shouldn't be used.[0] I have seen two ways of what you are asking for: <http://example.com/endpoint/?A=111&A=222&A=333> and <http://example.com/endpoint/?A_1=111&A_2=222&A_3=333>. I don't see the issue with having to build an array for the values. If the sender is sending an array the recipient should receive an array. [0]: <https://perishablepress.com/stop-using-unsafe-characters-in-urls/>
participants (6)
-
Alex Beamish
-
Jamon Camisso
-
lsorense@csclub.uwaterloo.ca
-
Myles Braithwaite 👾
-
ted leslie
-
William Park