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

[REBOL] Re: CGI: reading POST-method data with read-io

From: g:santilli:tiscalinet:it at: 24-Aug-2000 19:37

Hello [alex--pini--mclink--it]! On 24-Ago-00, you wrote: a> I've read the User's Guide, the old FAQs, the how-to and the a> recent Networking chapter, but I still lack insight on the a> inner workings of read-io. I can make conjectures, they may a> even work, but I don't like that: in the long run, I could a> accumulate all sorts of mistakes. I hope I can help... a> ---------- Buffer ---------- a> We need a buffer. If we need to read 2000 bytes, the buffer is a> made 2002 bytes long with a> data1: make string! 2002 (This is probably a bug. I think it was going to be fixed...) a> I guess the extra 2 bytes are needed to store ancillary a> information, but their content is not my concern, for now. Can a> we make the buffer as in a> data2: make string! 2000 You should be able to, but it creates problems if the length is a multiple of 16. I had a lot of troubles because of this... :-) a> or even a> data3: copy "" READ-IO is very low-level, and does not extend the string. Anyway, since the new experimental release of core has asyncronous TCP ports, READ-IO should no more be needed. a> ---------- Correct buffer-length ---------- a> According to CGI quasi-official specs, once I've checked the a> message body is in URL-encoded format, I must read no more a> than CONTENT_LENGTH bytes from system/ports/input. So if I a> want to go elegant and read *exactly* CONTENT_LENGTH bytes I a> make my buffer exactly 2 bytes longer than that and use a> read-io to read exactly CONTENT_LENGTH bytes, so I don't waste a> memory in a prudent 128 MB buffer, right? Yup. a> ---------- Data readiness ---------- [...] a> CONTENT_LENGTH is, say, 22000 bytes, what happens if I request a> my 22000 bytes but only 1000 are available? Will read-io a> return the 1000 bytes immediately (which means I have to do Yes. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila --