cc'ing the modperl list > I tested the new module and basicly it seems to works fine with my > application. However you overlooked something obvious in your > implementation. > > The problem occurs when trying to download a binary attachment. This > produced server errors: > > [Tue Jun 8 18:38:14 2004] [error] Can't locate object method "BINMODE" > via package "Apache::HEADRegistry" at /home/santa/cgi-test/script.pl > line 20.
are you running on windows? the only time I have ever seen binmode required is for win32. > > From the error, you'll obviously directly see what is missing and this > was the way I fixed it: [snip] well, in Apache.xs BINMODE is a no-op, so I have coded it that way and it seems to work just the same. let me know if it works for you. > This example works fine after applying the above patch. Before it did not. ok, an updated version is here: http://www.modperlcookbook.org/~geoff/modules/Apache-HEADRegistry-0.01.tar.gz > > Notice that I also fixed the PRINTF (however I didn't test it), because > sooner or later a CGI script is gone use a printf-statement and that > would break. yeah, well, there is write() too :) but I've incorporated a PRINTF implementation, so we're covered there - write() is far less common and can be added later. > I made me the OO-guy in me think however, that what we're > doing might not be the most elegant/robust solution. The "Apache" module > itself is already used to be tied to STDOUT. It already appropriately > implements BINMODE, PRINT, etc. It therefore seems to make sense to also > tie something to STDOUT that is a subclass of the Apache class (but that > overides the PRINT method however by a method that conditionally invokes > $self->SUPER::PRINT). Then we wouldn't have to write "adaptor"-methods > like the BINMODE from my patch. > One approach might be to make Apache::HEADRegistry mutli-inheret from > Apache::RegistryNG as well as Apache. Or to tie not the > Apache::HEADRegistry class itself to STDOUT, but a helper class that is > an Apache subclass. well, the Apache class (and it's write operations) _are_ the problem - outside of BINMODE (and a handful of others that aren't relevant, like TELL) the write-based TIEHANDLE functions in Apache.xs need to be intercepted and made HEAD compliant. so, there is really little that we could reuse from the Apache class. and taking this approach is the path of least resistance - it's already mostly done :) > > What do you think? You will certainly have a lot more perltie and mod_perl > experience than I do, so this might be obviously a bad idea for some > reason. well, I think you're on the right track adding BINMODE and PRINTF. give the latest version a whirl and let me know. and thanks for your feedback and effort! --Geoff -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html