Re: Cryptic Apache::Registry read() behavior
if anybody wants to confirm that this won't break anything (e.g. CGI.pm), this patch will clear the buffer before appending to it. --- Apache/Apache.pm2000/08/15 04:35:13 1.52 +++ Apache/Apache.pm2000/08/16 04:36:30 @@ -65,7 +65,7 @@ my($nrd, $buf, $total); $nrd = $total = 0; $buf = ""; -$_[1] ||= ""; +$_[1] = ""; #$_[1] = " " x $bufsiz unless defined $_[1]; #XXX? $r->hard_timeout("Apache->read");
Re: Cryptic Apache::Registry read() behavior
On Fri, 30 Jun 2000, Cyrus Rahman wrote: > Hmm, I was just adapting a large application I wrote some years ago to work > with mod_perl. Much to my amazement, despite its complexity and the fact that > it was largely written before mod_perl, it worked without modification! Well, > almost. There is one problem: > > When handling form uploads, it calls read() from perl and expects it to act > just like the perl version. But Apache.pm's read() does one notable thing > differently. If you do a 'read(STDIN, $buf, $size)', Apache.pm's read > concatenates the new data to the previous contents of $buf instead of replacing > it. > > Now it is not that hard to clear the buffer before each read, but the unusual > behavior breaks other things too, like the form uploads in CGI_Lite. Is the > concatenation an intentional feature, or is it a bug? hmm, Apache::read() has not been touched for something like 2-3 years. i don't recall if it's a feature (e.g. something CGI.pm needs), so i hesitate to change it at this point. > Besides this it really is remarkable how perfectly mod_perl reproduces the CGI > environment! good news :)
Cryptic Apache::Registry read() behavior
Hmm, I was just adapting a large application I wrote some years ago to work with mod_perl. Much to my amazement, despite its complexity and the fact that it was largely written before mod_perl, it worked without modification! Well, almost. There is one problem: When handling form uploads, it calls read() from perl and expects it to act just like the perl version. But Apache.pm's read() does one notable thing differently. If you do a 'read(STDIN, $buf, $size)', Apache.pm's read concatenates the new data to the previous contents of $buf instead of replacing it. Now it is not that hard to clear the buffer before each read, but the unusual behavior breaks other things too, like the form uploads in CGI_Lite. Is the concatenation an intentional feature, or is it a bug? Besides this it really is remarkable how perfectly mod_perl reproduces the CGI environment! Cyrus