• Welcome to The Network People Support Forums. Please login or sign up.

Updated patch (hack) for mod_perl 2.0

Started by matt, June 09, 2005, 11:00:03 AM

Previous topic - Next topic

matt

Now that mod_perl 2 is out and they've broken all the compatability with mod_perl 1.99...

Here's a quick and dirty hack that gets NicTool with Apache and mod_perl 2.0.  Maybe someday I'll clean it up and do a proper patch but for now, this does the trick.

--- HTTP.pm.orig   Mon Aug 18 13:44:21 2003
+++ HTTP.pm   Thu Jun  9 16:31:30 2005
@@ -10,11 +10,20 @@

package SOAP::Transport::HTTP;

-use strict;
+#use strict;
use vars qw($VERSION);
$VERSION = sprintf("%d.%s", map {s/_//g; $_} q$Name: release-0_60-public $ =~ /-(\d+)_([\d_]+)/);

use SOAP::Lite;
+#use Apache2;
+use mod_perl2;
+
+
+BEGIN {
+    require Apache2::Const;
+    Apache::Const->import(-compile => qw(OK DECLINED));
+}
+

#  ============================================================ ==========

@@ -441,7 +450,11 @@

sub DESTROY { SOAP::Trace::objects('()') }

-sub new { require Apache; require Apache::Constants;
+sub new {
+  #require Apache; require Apache::Constants;
+#  require Apache2;
+#  require Apache::RequestRec;
+  require Apache2::Const;
  my $self = shift;

  unless (ref $self) {
@@ -453,13 +466,16 @@
}

sub handler {
+  require Apache2::RequestIO;
+  require Apache2::RequestRec;
+
  my $self = shift->new;
  my $r = shift || Apache->request;

  $self->request(HTTP::Request->new(
    $r->method => $r->uri,
    HTTP::Headers->new($r->headers_in),
-    do { my $buf; $r->read($buf, $r->header_in('Content-length')); $buf; }
+    do { my $buf; $r->read($buf, $r->headers_in->{'Content-length'}); $buf; }
  ));
  $self->SUPER::handle;

@@ -470,15 +486,17 @@
  # will emulate normal response, but with custom status code
  # which could also be 500.
  $r->status($self->response->code);
-  $self->response->headers->scan(sub { $r->header_out(@_) });
-  $r->send_http_header(join '; ', $self->response->content_type);
+  $self->response->headers->scan(sub { $r->headers_out->{@_} });
+  #$r->send_http_header(join '; ', $self->response->content_type);
+  $r->content_type(join '; ', $self->response->content_type);
  $r->print($self->response->content);
-  &Apache::Constants::OK;
+  return Apache2::Const::OK;
}

sub configure {
  my $self = shift->new;
  my $config = shift->dir_config;
+  require APR::Table;
  foreach (%$config) {
    $config->{$_} =~ /=>/
      ? $self->$_({split /\s*(?:=>|,)\s*/, $config->{$_}})
@@ -591,7 +609,7 @@
=item mod_soap server (.htaccess, directory-based access)

  SetHandler perl-script
-  PerlHandler Apache::SOAP
+  PerlResponseHandler Apache::SOAP
  PerlSetVar dispatch_to "/Your/Path/To/Deployed/Modules, Module::Name, Module::method"
  PerlSetVar options "compress_threshold => 10000"

@@ -808,7 +826,7 @@

  <Location /soap>
    SetHandler perl-script
-    PerlHandler SOAP::Apache
+    PerlResponseHandler SOAP::Apache
  </Location>

Apache.pm:
@@ -831,7 +849,7 @@
  Alias /mod_perl/ "/Apache/mod_perl/"
  <Location /mod_perl>
    SetHandler perl-script
-    PerlHandler Apache::Registry
+    PerlResponseHandler Apache::Registry
    PerlSendHeader On
    Options +ExecCGI
  </Location>

LogicX

Just to add to this -- new version of p5-Apache-DBI came out today in ports:

www/p5-Apache-DBI
 Unbreak after the mod_perl2 API dance.
 
 Approved by:     skv (maintainer)
 Obtained from:  Philip M. Gollucci (pgollucci [at] p6m7g8.com) (largely)
 08 Jun 2005 - philip
 http://www.FreshPorts.org/www/p5-Apache-DBI/" target="_blank">http://www.FreshPorts.org/www/p5-Apache-DBI/
--- May this post be indexed by spiders, and archived for all to see as my internet epitaph.
http://FPuX.com" target="_blank">http://FPuX.com

LogicX

Here's what I believe to be the identical patch -- just re-posted wrapped in pre tags, so you can copy/paste it and it maintains the correct indenting

-- apparently one of the hunks STILL doesn't copy out of here correctly, so I offer a URL where you can http://LogicX.net/projects/HTTP.pm.patch" target="_blank">download it.

Also, be sure to install the www/p5-CGI.pm port so it overwrites the default perl CGI.pm -- the port is updated to work with the new mod_perl

--- HTTP.pm.orig        Mon Aug 18 14:44:21 2003+++ HTTP.pm     Tue Jul  5 01:29:31 2005@@ -10,11 +10,19 @@ package SOAP::Transport::HTTP;-use strict;+#use strict; use vars qw($VERSION); $VERSION = sprintf("%d.%s", map {s/_//g; $_} q$Name: release-0_60-public $ =~ /-(\d+)_([\d_]+)/); use SOAP::Lite;+#use Apache2;+use mod_perl2;+++BEGIN {+  require Apache2::Const;+  Apache::Const->import(-compile => qw(OK DECLINED));+} # ======================================================================@@ -441,7 +449,11 @@ sub DESTROY { SOAP::Trace::objects('()') }-sub new { require Apache; require Apache::Constants;+sub new {+  # require Apache; require Apache::Constants;+  # require Apache2;+  # require Apache::RequestRec;+  require Apache2::Const;   my $self = shift;   unless (ref $self) {@@ -453,13 +465,16 @@ } sub handler {+  require Apache2::RequestIO;+  require Apache2::RequestRec;+   my $self = shift->new;   my $r = shift || Apache->request;   $self->request(HTTP::Request->new(     $r->method => $r->uri,     HTTP::Headers->new($r->headers_in),-    do { my $buf; $r->read($buf, $r->header_in('Content-length')); $buf; }+    do { my $buf; $r->read($buf, $r->headers_in->{'Content-length'}); $buf; }   ));   $self->SUPER::handle;@@ -470,15 +485,17 @@   # will emulate normal response, but with custom status code   # which could also be 500.   $r->status($self->response->code);-  $self->response->headers->scan(sub { $r->header_out(@_) });-  $r->send_http_header(join '; ', $self->response->content_type);+  $self->response->headers->scan(sub { $r->headers_out->{@_} });+  #$r->send_http_header(join '; ', $self->response->content_type);+  $r->content_type(join '; ', $self->response->content_type);   $r->print($self->response->content);-  &Apache::Constants::OK;+  return Apache2::Const::OK; } sub configure {   my $self = shift->new;   my $config = shift->dir_config;+  require APR::Table;   foreach (%$config) {     $config->{$_} =~ /=>/       ? $self->$_({split /\s*(?:=>|,)\s*/, $config->{$_}})@@ -591,7 +608,7 @@ =item mod_soap server (.htaccess, directory-based access)   SetHandler perl-script-  PerlHandler Apache::SOAP+  PerlResponseHandler Apache::SOAP   PerlSetVar dispatch_to "/Your/Path/To/Deployed/Modules, Module::Name, Module::method"   PerlSetVar options "compress_threshold => 10000"@@ -808,7 +825,7 @@   <Location /soap>     SetHandler perl-script-    PerlHandler SOAP::Apache+    PerlResponseHandler SOAP::Apache   </Location> Apache.pm:@@ -831,7 +848,7 @@   Alias /mod_perl/ "/Apache/mod_perl/"   <Location /mod_perl>     SetHandler perl-script-    PerlHandler Apache::Registry+    PerlResponseHandler Apache::Registry     PerlSendHeader On     Options +ExecCGI   </Location>
--- May this post be indexed by spiders, and archived for all to see as my internet epitaph.
http://FPuX.com" target="_blank">http://FPuX.com