cgi mc/large data reads

Sadhunathan Nadesan sadhu at castandcrew.com
Sat Jan 4 11:10:00 EST 2003


| Date: Sat, 04 Jan 2003 07:37:12 -0800
| To: sadhu at castandcrew.com
| From: Sannyasin Sivakatirswami <katir at hindu.org> (by way of Sadhunathan Nadesan <sadhu at nadesan.org>)
| Subject: Re: cgi mc/large data reads
| 
| Om Sadhunathan: 
| 
| Wonderful! 
| 
| You might tell Scott that. I am sure he would appreciate feedback... 
| 
| And, can you send me a script with the patch installed? I want to convert
| our guestbook over to MC, but have been very reluctant to do so because
| of this problem. Even the PERL script was chopping an long comments sent
| (though that might be a problem in the client browser and not necessarily
| on formmail.pl) and we haven't been able to do anything else with in
| coming guestbook sign ins because i don't know PERL. this weill be an
| excellent area for Saravana to get hold of. 
| 
| Om Sivakatirswami 


Namaste, Swami,

Sorry for the slow response.

Ok, I will post this on the list, which I believe Scott reads.  The
context of the feedback you mention is that at work, I had to replace an
MC cgi script with a Perl script because of erratic performance by MC -
it did not always, but sometimes, would get nothing at all as input from
an html form using the algorithm: "read from stdin until empty" which is seen
in examples all over the place explaining how to do scripting on Unix.
At first Scott was not able to duplicate this problem until he got a
faster server and started noticing it himself, whereupon, he posted a
work around.  I tried the work around on our application program (which
happened to be mission critical - it was used by customers to approve
invoices, so having it sometimes fail was totally unacceptable!) and it
fixed the problem.

I mentioned to you this was a good thing because it would be sad if our
IT staff could not trust MC, we'd never be able to use it for anything.
The entrance barrier is hard enough due to the lack of documentation,
plus general programmer arrogance.  We can't buy books on MC, there is no
manual, etc.  But I want to be able to use it, despite the fact that my
staff are expert C and Perl programmers and resist anything that takes
the power of IT out of the hands of the few (them) and into the hands of
the many (much easier to learn MC than C).  So the fact that it didn't
work made it instantly rejected.

Anyway, here is an RCS diff .. I basically replaced the first part with the
2nd part below.  I'm sort of ignoring the 'get' method from forms because
the form behind this cgi doesn't use it, I more or less left that in as a
comment to remind me of the old way whenever I see this code.  I don't
necessarily recommend copying what I did, but it will give you the idea.



Was:

<   read from stdin until empty
<   put urlDecode(it) into formdata

---

Now is:

>   if ($REQUEST_METHOD = "POST") then
>     put empty into buffer
>     repeat until length(buffer) >= $CONTENT_LENGTH
> 	 read from stdin until empty
> 	 put it after buffer
>     end repeat
>   else
>     read from stdin until empty
>     put it into buffer
>   end if
> 
>   put urlDecode(buffer) into formdata



More information about the metacard mailing list