Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: CGI POST input

From: joel:neely:fedex at: 19-Nov-2000 23:27

Hello, Allen, I tested it and it didn't work. |-( Details below. [rebol-bounce--rebol--com] wrote:
> From: "Joel Neely" <[joel--neely--fedex--com]> > > > > I get failure if the form uses POST and the combined length of all > > name/value pairs exceeds 4104 bytes, which is apparently the max > > length returned by a single call to input (this is consistent). > > I.e., the rest of the data are lost. > > Hi Joel, > > This a new entry in the Official FAQ which may be of use here. > > http://www.rebol.com/faq.html#14982631 > > I haven't tested it on anything large yet. >
Here's the form I created for the test. <html> <head><title>Test CGI with form</title></head> <body> <h3>Test CGI with form</h3> <form method="post" action="testcgi.r.cgi"> Text area: <textarea name="area" rows="15" cols="50">Hello</textarea><br /> Text field: <input type="text" name="field" size="10" value="Goodbye"><br /> <input name="submit" type="submit" value="Submit"> <input name="reset" type="reset" value="Reset"> <input name="secret" type="hidden" value="whisper"> </form> </body> </html> ... and here's the first script ... #!/usr/local/bin/rebol -cs REBOL [] read-post-input: func [/local cs] [ ; cs: copy system/ports/input cs: input return cs ] clen: to-integer system/options/cgi/content-length reqm: system/options/cgi/request-method cont: any [ if reqm = "get" [ system/options/cgi/query-string ] if reqm = "post" [ input ] ] print [ {Content-type: text/plain^/^/} {^/request-method: } system/options/cgi/request-method {^/content-length: } clen {^/content: } cont {^/length?: } length? cont newline ] When I put large quantities of text into the textarea, the script produces the following output ... request-method: POST content-length: 6771 content: area=12345678901234567890123456789012345678901234567890%0D%0A1... length?: 4094 Note the "magic number" of 4094 bytes in the actual length retrieved, even though the form sent over 6.5K. The second attempt just swapped the source of data in the Read-Post-Input function... #!/usr/local/bin/rebol -cs REBOL [] read-post-input: func [/local cs] [ cs: copy system/ports/input ; cs: input return cs ] clen: to-integer system/options/cgi/content-length reqm: system/options/cgi/request-method cont: any [ if reqm = "get" [ system/options/cgi/query-string ] if reqm = "post" [ read-post-input ] ] print [ {Content-type: text/plain^/^/} {^/request-method: } system/options/cgi/request-method {^/content-length: } clen {^/content: } cont {^/length?: } length? cont newline ] ...which produced... request-method: POST content-length: 53 content: area=Hello&field=Goodbye&submit=Submit&secret=whisper length?: 1 ...using the default form content. Notice the peculiar fact that the length is being reported as 1 (???) However, this one also hits the proverbial wall when the input exceeds 4094 bytes in length. Sooooo... I'm still open for suggestions, but it's not looking too good for the home team at this point. -jn-