[REBOL] read-io Problems in CGI
From: tim::johnsons-web::com at: 9-Aug-2001 16:13
Quite some time ago, I set up a read routine for a cgi program.
I used an example that I found at a web site. (can't remember which).
I modified the example so that it went like this :
read-data: func[/local tmp stdin dstr] [
either system/options/cgi/request-method = "POST"[
either (tmp: to-integer
load any[system/options/cgi/content-length "0"])> 0[
tmp: tmp + 10
; tmp is incremented by 10
stdin: make string! tmp ; allocate storage space
read-io system/ports/input stdin tmp
][none] ; data string empty
either has-data? dstr[dstr][none]
]; end either
]; end read-data --------------------
;Note that tmp is incremented by 10.
; I recently commented out the increment to 'tmp. Thus
; rendering tmp exactly equal to 'content-length.
; I then found that there were occasional situations in which
; one byte was dropped from the data during a read from a "POST"
; That is - it "appears" that
; sometimes 'read-io reads one less byte than the value of 'tmp
; Has anyone else had this problem?
; Perhaps someone might see something wrong with my code here?