[REBOL] Re: html post
From: brett:codeconscious at: 8-Aug-2002 17:43
Hi Andrew,
> For the example code, yes. In my Rebol/Wiki, where it works well, I use:
>
> Query: make string! 2 + Length: to-integer
> Rebol/options/cgi/content-length
> read-io Rebol/ports/input Query Length
>
> and so I know the length needed.
Again, I seem to recall that there was a problem with relying on
content-length, but if it is working for you then hey who am I to disagree!
:^)
Here is an excerpt from a script of mine that process standard input for the
NoteTab editor. So it is not CGI, but very related. The relevent bit is the
while loop condition that checks for the result of READ-IO which I think is
the number of bytes read. I've no idea how this would react in a CGI
environment, maybe if you have a webserver on your personal machine you
could try it? You could probaby ignore my character manipulations (they are
probably only relevent to my editor usage).
standard-input: function [
"Returns a string that comes from standard input."
; May not be suitable for large input streams.
] [buf-size inp inp-buffer log] [
buf-size: 30000
inp-buffer: make string! buf-size
inp: make string! buf-size
while [
clear inp-buffer
0 < read-io system/ports/input inp-buffer buf-size
] [
replace/all inp-buffer "^M" "" ; Handles CR on windows systems.
append inp inp-buffer
]
inp
if all [
0 < length? inp
equal? last inp to-char 26
] [
remove/part at inp length? inp 1
]
inp
]
Regards,
Brett.