RE: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-27 Thread Geoffrey Young



 -Original Message-
 From: Jean-Michel Hiver [mailto:[EMAIL PROTECTED]]
 Sent: Monday, November 26, 2001 9:38 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Apache::Registry HTTP HEAD feature fix ;-)
 
 
  well, I just gave you a patch that worked :)  basically, it 
 only provides a
  solution for mod_cgi compatible scripts, but if you're 
 using the mod_perl
  API then it is up to you to check $r-header_only and take 
 appropriate
  action...
 
 True, however your patch also means that it's necessary to recompile
 stuff, which is not always possible. In addition (and as an exercise)
 I'd be happy to find a clean Perl way to do it.
 

this should work for scripts that only use print() (without the patch I sent
yesterday :)

--Geoff

package My::HEADRegistry;

use Apache::Constants qw(DONE);
use Apache::RegistryNG;
use strict;

@My::HEADRegistry::ISA = qw(Apache::RegistryNG);

sub new {

  my ($class, $r) = @_;

  $r ||= Apache-request;

  tie *STDOUT, $class, $r;

  return tied *STDOUT;
}

sub PRINT {

  my ($self, @data) = @_;

  my $r = $self-{r};

  # we're emulating mod_cgi, where there is no auto-dereferencing...
  my $data = join '', @data;

  my $dlm = \015?\012; # a bit borrowed from LWP::UserAgent
  my ($key, $value);
  local $_;

  unless ($r-sent_header) {
# if we have already sent the headers, no reason to scan the output

while(($_, $data) = split /$dlm/, $data, 2) {
  # scan the incoming data for headers

  if ($_  /^(\S+?):\s*(.*)$/) {
# if the data looks like a header, add it to the header table

($key, $value) = ($1, $2);

last unless $key;

$r-cgi_header_out($key, $value);
  }
}
  }

  # send the headers unless we've already sent them
  $r-send_http_header  $r-sent_header(DONE)
unless $r-sent_header;

  # if this is a HEAD request, we're done
  return if $r-header_only;

  # otherwise, send whatever data we have left to the client
  $r-write_client($data);
}

sub TIEHANDLE {

  my ($class, $r) = @_;

  return bless { r = $r }, $class;
}
1;



Re: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-27 Thread Jean-Michel Hiver

 this should work for scripts that only use print() (without the patch I sent
 yesterday :)

Looks neat! I'll make sure I'll take a close look at that :-)
Cheers,
-- 
== \__ =
   /\/\  IT'S TIME FOR A DIFFERENT KIND OF WEB 
  / /\__/\ \
_/_/_/\/\_\_  Jean-Michel Hiver - Software Director
 \ \ \/*/ /   [EMAIL PROTECTED]+44 (0)114 221 4968
  \ \/__\/   
   \/\   VISIT HTTP://WWW.MKDOC.COM 
== / ===



RE: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-27 Thread Geoffrey Young



 -Original Message-
 From: Jean-Michel Hiver [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 27, 2001 9:02 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Apache::Registry HTTP HEAD feature fix ;-)
 
 
  this should work for scripts that only use print() (without 
 the patch I sent
  yesterday :)
 
 Looks neat! I'll make sure I'll take a close look at that :-)
 Cheers,

BTW, I think I figured out why your redirect to /dev/null was working...
CGI.pm can tell if it is running under mod_perl and sets its header()
routine to add the headers to the outgoing header table using mod_perl
methods.  thus, the headers go directly to the client while the content
stays put.  however, if you don't use CGI.pm your old solution doesn't
work...

anyway, I haven't stressed the solution I just posted too much, but I did
test both CGI.pm and non-CGI.pm cases with multiple print statements and it
seems to work ok... time will tell :)

HTH

--Geoff



RE: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-26 Thread Geoffrey Young



 -Original Message-
 From: Jean-Michel Hiver [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, November 25, 2001 7:43 AM
 To: [EMAIL PROTECTED]
 Subject: Apache::Registry HTTP HEAD feature fix ;-)
 
 
 Hi guys,
 
   As promised I have been producing a fix for Apache::Registry. The
   module is called MKDoc::Registry because it will be integrated in
   the piece of software I'm working on, but feel free to do 
 whatever you
   want with it.
 
   A slight litte issue is that I really don't understand why 
 this module
   is working at all (read the code), but it's just working 
 fine... could
   you please test it and tell me what's going on?
 
   PS: On my system the file is located here:
   /usr/lib/perl5/site_perl/5.6.0/i386-linux/MKDoc/Registry.pm
 

well, you should be subclassing Apache::RegistryNG instead of
Apache::Registry - then your method calls would work :)

personally, I'm not too keen on a core patch that comes with I don't
understand why... but it works and this approach seems kinda kludgy
anyway...

this simple patch to Apache::write_client seems to have the desired effect.
tested with both normal CGI script and mod_perl API calls.

--Geoff

--- src/modules/perl/Apache.xs  Fri Sep 28 14:43:13 2001
+++ ../apache-1.3/src/modules/perl/Apache.xsMon Nov 26 08:46:04 2001
@@ -1166,7 +1166,7 @@
 CODE:
 RETVAL = 0;
 
-if (r-connection-aborted)
+if (r-connection-aborted || r-header_only)
 XSRETURN_IV(0);
 
 for(i = 1; i = items - 1; i++) {




Re: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-26 Thread Jean-Michel Hiver

 well, you should be subclassing Apache::RegistryNG instead of
 Apache::Registry - then your method calls would work :)

Sorry, Although I'm good at OO-Perl and CGI programming, I'm really
quite new to mod_perl thus I really don't know what the fuck I'm doing
:-)

What is the difference between Apache::Registry and Apache::RegistryNG ?
(a simple RTFM followed by a URI would be welcome).


 personally, I'm not too keen on a core patch that comes with I don't
 understand why... but it works and this approach seems kinda kludgy
 anyway...

I totally agree, it's a horrible hack, and I'll be willing to provide
something much better when I understand what's going on and why
Apache::Registry seems to be reluctant to let its methods change ;-)


Cheers,
-- 
== \__ =
   /\/\  IT'S TIME FOR A DIFFERENT KIND OF WEB 
  / /\__/\ \
_/_/_/\/\_\_  Jean-Michel Hiver - Software Director
 \ \ \/*/ /   [EMAIL PROTECTED]+44 (0)114 221 4968
  \ \/__\/   
   \/\   VISIT HTTP://WWW.MKDOC.COM 
== / ===



RE: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-26 Thread Geoffrey Young



 -Original Message-
 From: Jean-Michel Hiver [mailto:[EMAIL PROTECTED]]
 Sent: Monday, November 26, 2001 9:18 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Apache::Registry HTTP HEAD feature fix ;-)
 
 
  well, you should be subclassing Apache::RegistryNG instead of
  Apache::Registry - then your method calls would work :)
 
 Sorry, Although I'm good at OO-Perl and CGI programming, I'm really
 quite new to mod_perl thus I really don't know what the  I'm doing
 :-)
 
 What is the difference between Apache::Registry and 
 Apache::RegistryNG ?
 (a simple RTFM followed by a URI would be welcome).

I believe that is in the perl.apache.org/guide

 
 
  personally, I'm not too keen on a core patch that comes 
 with I don't
  understand why... but it works and this approach seems kinda kludgy
  anyway...
 
 I totally agree, it's a horrible hack, and I'll be willing to provide
 something much better when I understand what's going on and why
 Apache::Registry seems to be reluctant to let its methods change ;-)
 

well, I just gave you a patch that worked :)  basically, it only provides a
solution for mod_cgi compatible scripts, but if you're using the mod_perl
API then it is up to you to check $r-header_only and take appropriate
action...

--Geoff 



Re: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-26 Thread Jean-Michel Hiver

 well, I just gave you a patch that worked :)  basically, it only provides a
 solution for mod_cgi compatible scripts, but if you're using the mod_perl
 API then it is up to you to check $r-header_only and take appropriate
 action...

True, however your patch also means that it's necessary to recompile
stuff, which is not always possible. In addition (and as an exercise)
I'd be happy to find a clean Perl way to do it.

Best regards,
-- 
== \__ =
   /\/\  IT'S TIME FOR A DIFFERENT KIND OF WEB 
  / /\__/\ \
_/_/_/\/\_\_  Jean-Michel Hiver - Software Director
 \ \ \/*/ /   [EMAIL PROTECTED]+44 (0)114 221 4968
  \ \/__\/   
   \/\   VISIT HTTP://WWW.MKDOC.COM 
== / ===



Apache::Registry HTTP HEAD feature fix ;-)

2001-11-25 Thread Jean-Michel Hiver

Hi guys,

  As promised I have been producing a fix for Apache::Registry. The
  module is called MKDoc::Registry because it will be integrated in
  the piece of software I'm working on, but feel free to do whatever you
  want with it.

  A slight litte issue is that I really don't understand why this module
  is working at all (read the code), but it's just working fine... could
  you please test it and tell me what's going on?

  PS: On my system the file is located here:
  /usr/lib/perl5/site_perl/5.6.0/i386-linux/MKDoc/Registry.pm

Cheers,
-- 
== \__ =
   /\/\  IT'S TIME FOR A DIFFERENT KIND OF WEB 
  / /\__/\ \
_/_/_/\/\_\_  Jean-Michel Hiver - Software Director
 \ \ \/*/ /   [EMAIL PROTECTED]+44 (0)114 221 4968
  \ \/__\/   
   \/\   VISIT HTTP://WWW.MKDOC.COM 
== / ===



Registry.pm
Description: Perl program


Re: Apache::Registry HTTP HEAD feature fix ;-)

2001-11-25 Thread brian moseley


instead of redirecting stdout to /dev/null, how about
redirecting it to a temporary buffer? that way you can
calculate the size of the output and set the content length
on the response.

On Sun, 25 Nov 2001, Jean-Michel Hiver wrote:

 Hi guys,

   As promised I have been producing a fix for Apache::Registry. The
   module is called MKDoc::Registry because it will be integrated in
   the piece of software I'm working on, but feel free to do whatever you
   want with it.

   A slight litte issue is that I really don't understand why this module
   is working at all (read the code), but it's just working fine... could
   you please test it and tell me what's going on?

   PS: On my system the file is located here:
   /usr/lib/perl5/site_perl/5.6.0/i386-linux/MKDoc/Registry.pm

 Cheers,