Hi Nicolas, This is a total guess, but... If your script is running in a Unix or Linux environment, I bet there's a system buffer size setting (different from an HTTP server environment variable). I don't know where or what it would be... just navigating by intuition here. Whatever that system value is, it's probably the optimum chunk size for "getting" from STDIN.
Can anyone confirm/deny this? Thanks. Phil ----- Original Message ----- From: "Nicolas Cueto" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, November 02, 2001 3:45 AM Subject: Re: stdin buffer size limit? > Hi, > > Sorry to persist about this... > > I'm still vexed with my mt script (it's the "action" to a form, which > processes and returns text data all via a browser) and about why, depending > on the number of characters submitted thru a form's submit button > (textarea), stdin sometimes successfully reads in and processes the data > when it's under about 1500 characters, while at othertimes stdin reads > nothing if the data is over that size -- or only reads it after I've hit the > form's submit button umpteen times. > > Most likely, this all stems from my fundamental ignorance of the http > process. For example, Andu wrote back: > > > > #!mc > > > on startup > > > if $REQUEST_METHOD is "POST" then > > > read from stdin until eof -- I also tried "until empty" > > > > There is no eof I don't think in the HTTP environment and "empty" can be > > anywhere. You have to be more precise: you know there is crlf & crlf > > between the header and the body so you read until you reach that point > > then you must look in what you read (the header) for the "Content > > Length:..." line (which your client *must* provide) and read for that > > length. > > Hmmm... I didn't know that exactly, except for seeing it at the foot of the > survey.mt script. So, any (polite!) suggestions where I could go online to > get a crash course on this. > > And if it's not simply my ignorace, but rather something I just haven't > mc-scripted correctly... help! (I hate when things work only some of the > time.) > > Thank you. > > Nicolas R Cueto > > ---------------------------------------------------- > ----- Original Message ----- > From: "andu" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, October 22, 2001 1:38 AM > Subject: Re: stdin buffer size limit? > > > > Nicolas Cueto wrote: > > > > > > Hi, > > > > > > The mt script below (Linux/Apache/MC2.3) successfully reads and return > html > > > form-data only when the form-data is short (less than 2-3 paragraphs). > When > > > the data is too long, a combination of several erratic behaviours can > > > happen: > > > > > > (1) data is read in and saved integrally into two files, but is returned > > > truncated > > > (2) data is neither saved into the files nor returned to the browser > (i.e., > > > the mt-generated page is returned, but data is missing from the textarea > > > form-objects) > > > (3) like (2), except the returned page appears "mutilated" (i.e., > snippets > > > of html coding appear in the places where the missing textarea > form-objects > > > ought to be) > > > (4) data is not saved into the files, and a completely blank page is > > > returned > > > > > > I checked the archives, especially Scott Raney's advice in > > > http://www.mail-archive.com/[email protected]/msg03228.html > that: > > > > > > > The actual buffer size depends on the version of UNIX > > > > and even on what type of descriptor is being written to > > > > and what the two ends are connected to. And the > > > > amount you'll get in a given "read until empty"also > > > > depends on CPU scheduling and how the process on the > > > > other end wrote it out. But none of this should matter > > > > if you do the reads correctly. > > > > > > Did I do the reads correctly? > > > > > > Thank you. > > > > > > Nicolas R Cueto > > > > > > %%%%%%% here's that script %%%%%%%%%%%%%%%%%%% > > > > > > #!mc > > > on startup > > > if $REQUEST_METHOD is "POST" then > > > read from stdin until eof -- I also tried "until empty" > > > > There is no eof I don't think in the HTTP environment and "empty" can be > > anywhere. You have to be more precise: you know there is crlf & crlf > > between the header and the body so you read until you reach that point > > then you must look in what you read (the header) for the "Content > > Length:..." line (which your client *must* provide) and read for that > > length. > > > > > put it into buffer -- do I need this line? > > > > Buffer is just the name of a variable. > > > > > set the itemDel to "&" > > > put item 1 of it into tRawData1 > > > put item 2 of it into tRawData2 > > > put urlDecode(tRawData1) into tData1 > > > put urlDecode(tRawData2) into tData2 > > > put tData1 into url "file:data1.txt" > > > put tData2 into url "file:data2.txt" > > > ## write out HTTP headers here ## > > > put "Content-Type: text/html" & crlf > > > put "Content-Length:" && the length of buffer & crlf & crlf > > > ## write the html file ## > > > -- a bunch of html here. Essentially a 3x2 table, > > > -- with 2 text area form objects into which > > > -- tData1 & tData2 are "put" > > > end if > > > end startup > > > > > > Archives: http://www.mail-archive.com/[email protected]/ > > > Info: http://www.xworlds.com/metacard/mailinglist.htm > > > Please send bug reports to <[EMAIL PROTECTED]>, not this list. > > > > Andu > > > > Archives: http://www.mail-archive.com/[email protected]/ > > Info: http://www.xworlds.com/metacard/mailinglist.htm > > Please send bug reports to <[EMAIL PROTECTED]>, not this list. > > > > > > > Archives: http://www.mail-archive.com/[email protected]/ > Info: http://www.xworlds.com/metacard/mailinglist.htm > Please send bug reports to <[EMAIL PROTECTED]>, not this list. > Archives: http://www.mail-archive.com/[email protected]/ Info: http://www.xworlds.com/metacard/mailinglist.htm Please send bug reports to <[EMAIL PROTECTED]>, not this list.
