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

[REBOL] Re: html post

From: petr:krenzelok:trz:cz at: 8-Aug-2002 12:02

Brett Handley wrote:
>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 >
I am interested in this condition here. We try to do some intensive Ethernet + tcp testing here with our device. Is that condition correct? What if your input is not fast enought to feed you with data? It does not necessarily mean, that you received all data, does it? What about following? input-port: open/direct/no-wait system/ports/input while [wait input-port data: copy input port][append inp data] I think it meets follwoing conditions conditions: - is async the same way read-io is, or so I think ... - 'wait should wait for input, so you will not receive empty string, if no data available - 'none is gonna be returned, if port is closed, while on the other hand we have problem with: - how to properly leave the loop? Maybe using something like: end-seq: "some-spec-chars or newline" while [ wait input-port data: copy port all [ data not found? find head inp end-seq] ][ append inp data] just in case you would want to try alternative aproach using 'copy .... I just hope I am not all that wrong :-) Cheers, -pekr-