[REBOL] Re: html post
From: al:bri:xtra at: 8-Aug-2002 7:37
> input-cgi: func [/stdin] [
> stdin: make string! 15000
> either system/options/cgi/request-method = "POST" [
> read-io system/ports/input stdin 15000
An important point I rediscovered in writing my Rebol/Wiki script, is to
make sure that the number in the call to read-io is one or two _*less*_ than
the allocated size! In other words, like:
stdin: make string! 15000 + 2 ; Required spare space for read-io!
either system/options/cgi/request-method = "POST" [
read-io system/ports/input stdin 15000
The relevant code from my Rebol/Wiki is:
if Post? [
use [Length] [ ; Extra length for use by Rebol's 'read-io.
Query: make string! 2 + Length: to-integer
Rebol/options/cgi/content-length
read-io Rebol/ports/input Query Length
Query
]
]
And for writing binary data, from my Rebol/Wiki:
Mime-Data: func [Mime [path!] Data [binary!]] [
print ["Content-Type:" :Mime newline]
write-io system/ports/output Data length? Data
quit
]
and used like:
Mime-Data 'application/pdf read/binary %MyAdobe.pdf
Andrew Martin
ICQ: 26227169 http://valley.150m.com/