[mb-commits] r9720 - in mb_server/branches/apache2: admin cgi-bin cgi-bin/MusicBrainz/Server cgi-bin/MusicBrainz/Server/Handlers/WS/1 cgi-bin/MusicBrainz/Server/Handlers/WS/Private htdocs/comp
root at musicbrainz.org
root at musicbrainz.org
Sat Mar 8 20:43:12 UTC 2008
Author: luks
Date: 2008-03-08 20:43:11 +0000 (Sat, 08 Mar 2008)
New Revision: 9720
Modified:
mb_server/branches/apache2/admin/startup.pl.default
mb_server/branches/apache2/admin/vh_httpd.conf.default
mb_server/branches/apache2/cgi-bin/MusicBrainz.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Artist.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Auth.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Common.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Label.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Release.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Tag.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Track.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/User.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/Private/Lookup.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/LogFile.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Mason.pm
mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/TRMGatewayHandler.pm
mb_server/branches/apache2/cgi-bin/QuerySupport.pm
mb_server/branches/apache2/cgi-bin/UserStuff.pm
mb_server/branches/apache2/cgi-bin/mq.pl
mb_server/branches/apache2/cgi-bin/mq_2_1.pl
mb_server/branches/apache2/cgi-bin/rdf.pl
mb_server/branches/apache2/cgi-bin/rdf_2_1.pl
mb_server/branches/apache2/htdocs/comp/redirect
Log:
Make this thing (somehow) work on Apache2+mod_perl2
Modified: mb_server/branches/apache2/admin/startup.pl.default
===================================================================
--- mb_server/branches/apache2/admin/startup.pl.default 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/admin/startup.pl.default 2008-03-08 20:43:11 UTC (rev 9720)
@@ -20,11 +20,11 @@
use lib "/home/httpd/musicbrainz/mb_server/cgi-bin";
# Make sure we are in a sane environment.
-$ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/
- or die "GATEWAY_INTERFACE not Perl!";
+#$ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/
+# or die "GATEWAY_INTERFACE not Perl!";
# cgi-bin/*.pl is run via Apache::Registry
-require Apache::Registry;
+require Apache2::Registry;
require Apache::Session;
require DBI;
@@ -114,12 +114,12 @@
require MusicBrainz::Server::Mason;
# Preload Apache::Registry scripts
-{
- use Apache::RegistryLoader ();
- my $r = Apache::RegistryLoader->new;
- $r->handler("/cgi-bin/$_", &DBDefs::MB_SERVER_ROOT."/cgi-bin/$_")
- for qw( mq.pl mq_2_1.pl rdf.pl rdf_2_1.pl );
-}
+#{
+# use Apache::RegistryLoader ();
+# my $r = Apache::RegistryLoader->new;
+# $r->handler("/cgi-bin/$_", &DBDefs::MB_SERVER_ROOT."/cgi-bin/$_")
+# for qw( mq.pl mq_2_1.pl rdf.pl rdf_2_1.pl );
+#}
# Mason will try to load these later, when $m->cache->... is used.
# Preload them.
Modified: mb_server/branches/apache2/admin/vh_httpd.conf.default
===================================================================
--- mb_server/branches/apache2/admin/vh_httpd.conf.default 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/admin/vh_httpd.conf.default 2008-03-08 20:43:11 UTC (rev 9720)
@@ -23,7 +23,7 @@
<Location /cgi-bin>
SetHandler perl-script
- PerlHandler Apache::Registry
+ PerlHandler Apache2::Registry
Options +ExecCGI
</Location>
@@ -36,7 +36,7 @@
# Uncomment this line to automatically reload modified Perl modules
# without having to restart Apache.
- #PerlInitHandler Apache::Reload
+ #PerlInitHandler Apache2::Reload
# But some is done here:
RewriteEngine on
@@ -257,6 +257,6 @@
</VirtualHost>
-PerlRestartHandler MusicBrainz::Server::LogFile::RestartHandler
+#PerlRestartHandler MusicBrainz::Server::LogFile::RestartHandler
# eof
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Artist.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Artist.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Artist.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,8 +27,8 @@
package MusicBrainz::Server::Handlers::WS::1::Artist;
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
+use Apache2::compat qw( );
use MusicBrainz::Server::Handlers::WS::1::Common qw( :DEFAULT apply_rate_limit );
sub handler
@@ -43,7 +43,7 @@
my $mbid = $1 if ($r->uri =~ /ws\/1\/artist\/([a-z0-9-]*)/);
- my %args; { no warnings; %args = $r->args };
+ my %args = $r->parse_args($r->args);;
my ($inc, $bad) = convert_inc($args{inc});
my ($info, $bad) = get_type_and_status_from_inc($bad);
if ($bad)
@@ -95,18 +95,18 @@
{
my $error = "$@";
print STDERR "WS Error: $error\n";
- $r->status(Apache::Constants::SERVER_ERROR());
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->status(Apache2::Const::SERVER_ERROR());
+ $r->content_type("text/plain; charset=utf-8");
$r->print($error."\015\012") unless $r->header_only;
- return Apache::Constants::SERVER_ERROR();
+ return Apache2::Const::SERVER_ERROR();
}
if (!defined $status)
{
- $r->status(Apache::Constants::NOT_FOUND());
- return Apache::Constants::NOT_FOUND();
+ $r->status(Apache2::Const::NOT_FOUND());
+ return Apache2::Const::NOT_FOUND();
}
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub serve_from_db
@@ -138,7 +138,7 @@
};
send_response($r, $printer);
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub print_xml
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Auth.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Auth.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Auth.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,8 +27,7 @@
package MusicBrainz::Server::Handlers::WS::1::Auth;
-use Apache::Constants qw( OK AUTH_REQUIRED SERVER_ERROR NOT_FOUND FORBIDDEN);
-use Apache::File ();
+use Apache2::Const qw( OK AUTH_REQUIRED SERVER_ERROR NOT_FOUND FORBIDDEN);
use Apache::AuthDigest::API;
use Digest::MD5 qw(md5_hex);
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Common.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Common.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Common.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -46,8 +46,7 @@
apply_rate_limit
);
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
use Encode qw( decode encode );
use Album;
use MusicBrainz::Server::Country;
@@ -223,19 +222,19 @@
{
my ($r, $error) = @_;
- $r->status(Apache::Constants::BAD_REQUEST());
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->status(Apache2::Const::HTTP_BAD_REQUEST());
+ $r->content_type("text/plain; charset=utf-8");
$r->print($error."\nFor usage, please see: http://musicbrainz.org/development/mmd\015\012") unless $r->header_only;
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub service_unavail
{
my ($r, $error) = @_;
- $r->status(Apache::Constants::HTTP_SERVICE_UNAVAILABLE());
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->status(Apache2::Const::HTTP_SERVICE_UNAVAILABLE());
+ $r->content_type("text/plain; charset=utf-8");
$r->print($error."\015\012") unless $r->header_only;
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
# Given the result of a RateLimit test ($t), return a response indicating that
@@ -243,15 +242,15 @@
sub rate_limited
{
my ($r, $t) = @_;
- $r->status(Apache::Constants::HTTP_SERVICE_UNAVAILABLE());
+ $r->status(Apache2::Const::HTTP_SERVICE_UNAVAILABLE());
$r->headers_out->add("X-Rate-Limited", sprintf("%.1f %.1f %d", $t->rate, $t->limit, $t->period));
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->content_type("text/plain; charset=utf-8");
unless ($r->header_only)
{
$r->print("Your requests are exceeding the allowable rate limit (" . $t->msg . ")\015\012");
$r->print("Please see http://wiki.musicbrainz.org/XMLWebService for more information.\015\012");
}
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
# Given a key (optional - defaults to something sensible), tests to see if the
@@ -289,10 +288,10 @@
&$printer();
}
- $r->status(Apache::Constants::HTTP_OK());
+ $r->status(Apache2::Const::HTTP_OK());
$r->set_content_length(length($xml));
- $r->send_http_header("text/xml; charset=utf-8");
- $r->print(\$xml) unless $r->header_only;
+ $r->content_type("text/xml; charset=utf-8");
+ $r->print($xml) unless $r->header_only;
}
sub xml_artist
@@ -1062,12 +1061,12 @@
}
else
{
- if ($response->code == Apache::Constants::NOT_FOUND())
+ if ($response->code == Apache2::Const::NOT_FOUND())
{
$out = '<?xml version="1.0" encoding="UTF-8"?>';
$out .= '<metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#"/>';
}
- elsif ($response->code == Apache::Constants::BAD_REQUEST())
+ elsif ($response->code == Apache2::Const::HTTP_BAD_REQUEST())
{
return bad_req($r, "Search server could not complete query: Bad request");
}
@@ -1078,11 +1077,11 @@
}
}
- $r->status(Apache::Constants::HTTP_OK());
+ $r->status(Apache2::Const::HTTP_OK());
$r->set_content_length(length($out));
- $r->send_http_header("text/xml; charset=utf-8");
+ $r->content_type("text/xml; charset=utf-8");
$r->print($out) unless $r->header_only;
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub xml_escape
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Label.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Label.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Label.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,8 +27,8 @@
package MusicBrainz::Server::Handlers::WS::1::Label;
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
+use Apache2::compat qw( );
use MusicBrainz::Server::Handlers::WS::1::Common qw( :DEFAULT apply_rate_limit );
sub handler
@@ -43,7 +43,7 @@
my $mbid = $1 if ($r->uri =~ /ws\/1\/label\/([a-z0-9-]*)/);
- my %args; { no warnings; %args = $r->args };
+ my %args = $r->parse_args($r->args);;
my ($inc, $bad) = convert_inc($args{inc});
my ($info, $bad) = get_type_and_status_from_inc($bad);
if ($bad)
@@ -92,19 +92,19 @@
{
my $error = "$@";
print STDERR "WS Error: $error\n";
- $r->status(Apache::Constants::SERVER_ERROR());
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->status(Apache2::Const::SERVER_ERROR());
+ $r->content_type("text/plain; charset=utf-8");
$r->print($error."\015\012") unless $r->header_only;
- return Apache::Constants::SERVER_ERROR();
+ return Apache2::Const::SERVER_ERROR();
}
if (!defined $status)
{
- $r->status(Apache::Constants::NOT_FOUND());
- return Apache::Constants::NOT_FOUND();
+ $r->status(Apache2::Const::NOT_FOUND());
+ return Apache2::Const::NOT_FOUND();
}
- $r->status(Apache::Constants::OK());
- return Apache::Constants::OK();
+ $r->status(Apache2::Const::OK());
+ return Apache2::Const::OK();
}
sub serve_from_db
@@ -135,7 +135,7 @@
};
send_response($r, $printer);
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub print_xml
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Release.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Release.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Release.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,8 +27,8 @@
package MusicBrainz::Server::Handlers::WS::1::Release;
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
+use Apache2::compat qw( );
use MusicBrainz::Server::Handlers::WS::1::Common qw( :DEFAULT apply_rate_limit );
use MusicBrainz::Server::CDTOC;
@@ -45,7 +45,7 @@
my $mbid = $1 if ($r->uri =~ /ws\/1\/release\/([a-z0-9-]*)/);
# Check general arguments
- my %args; { no warnings; %args = $r->args };
+ my %args = $r->parse_args($r->args);;
my ($inc, $bad) = convert_inc($args{inc});
if ($bad)
{
@@ -123,16 +123,16 @@
my $error = "$@";
print STDERR "WS Error: $error\n";
# TODO: We should print a custom 500 server error screen with details about our error and where to report it
- $r->status(Apache::Constants::SERVER_ERROR());
- return Apache::Constants::SERVER_ERROR();
+ $r->status(Apache2::Const::SERVER_ERROR());
+ return Apache2::Const::SERVER_ERROR();
}
if (!defined $status)
{
- $r->status(Apache::Constants::NOT_FOUND());
- return Apache::Constants::NOT_FOUND();
+ $r->status(Apache2::Const::NOT_FOUND());
+ return Apache2::Const::NOT_FOUND();
}
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub serve_from_db
@@ -189,7 +189,7 @@
};
send_response($r, $printer);
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub print_xml
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Tag.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Tag.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Tag.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,10 +27,10 @@
package MusicBrainz::Server::Handlers::WS::1::Tag;
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
+use Apache2::compat qw( );
use MusicBrainz::Server::Handlers::WS::1::Common;
-use Apache::Constants qw( OK BAD_REQUEST DECLINED SERVER_ERROR NOT_FOUND FORBIDDEN);
+use Apache2::Const qw( OK HTTP_BAD_REQUEST DECLINED SERVER_ERROR NOT_FOUND FORBIDDEN);
use MusicBrainz::Server::Tag;
use Data::Dumper;
@@ -46,11 +46,11 @@
return bad_req($r, "Only GET or POST is acceptable")
unless $r->method eq "GET";
- my $apr = Apache::Request->new($r);
+ my %args = $r->parse_args($r->args);;
my $user = $r->user;
- my $entity = $apr->param('entity');
- my $id = $apr->param('id');
- my $type = $apr->param('type');
+ my $entity = $args{'entity'};
+ my $id = $args{'id'};
+ my $type = $args{'type'};
if (!defined($type) || $type ne 'xml')
{
return bad_req($r, "Invalid content type. Must be set to xml.");
@@ -77,16 +77,16 @@
my $error = "$@";
print STDERR "WS Error: $error\n";
# TODO: We should print a custom 500 server error screen with details about our error and where to report it
- $r->status(Apache::Constants::SERVER_ERROR());
- return Apache::Constants::SERVER_ERROR();
+ $r->status(Apache2::Const::SERVER_ERROR());
+ return Apache2::Const::SERVER_ERROR();
}
if (!defined $status)
{
- $r->status(Apache::Constants::NOT_FOUND());
- return Apache::Constants::NOT_FOUND();
+ $r->status(Apache2::Const::NOT_FOUND());
+ return Apache2::Const::NOT_FOUND();
}
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub handler_post
@@ -96,12 +96,12 @@
# URLs are of the form:
# POST http://server/ws/1/tag/?name=<user_name>&entity=<entity>&id=<id>&tags=<tags>
- my $apr = Apache::Request->new($r);
+ my %args = $r->parse_args($r->args);;
my $user = $r->user;
- my $entity = $apr->param('entity');
- my $id = $apr->param('id');
- my $tags = $apr->param('tags');
- my $type = $apr->param('type');
+ my $entity = $args{'entity'};
+ my $id = $args{'id'};
+ my $tags = $args{'tags'};
+ my $type = $args{'type'};
if (!defined($type) || $type ne 'xml')
{
return bad_req($r, "Invalid content type. Must be set to xml.");
@@ -266,7 +266,7 @@
};
send_response($r, $printer);
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub print_xml
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Track.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Track.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Track.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,10 +27,10 @@
package MusicBrainz::Server::Handlers::WS::1::Track;
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
+use Apache2::compat qw( );
use MusicBrainz::Server::Handlers::WS::1::Common qw( :DEFAULT apply_rate_limit );
-use Apache::Constants qw( OK BAD_REQUEST DECLINED SERVER_ERROR NOT_FOUND FORBIDDEN);
+use Apache2::Const qw( OK HTTP_BAD_REQUEST DECLINED SERVER_ERROR NOT_FOUND FORBIDDEN);
sub handler
{
@@ -44,7 +44,7 @@
my $mbid = $1 if ($r->uri =~ /ws\/1\/track\/([a-z0-9-]*)/);
- my %args; { no warnings; %args = $r->args };
+ my %args = $r->parse_args($r->args);;
my ($inc, $bad) = convert_inc($args{inc});
if ($bad)
{
@@ -126,18 +126,18 @@
{
my $error = "$@";
print STDERR "WS Error: $error\n";
- $r->status(Apache::Constants::SERVER_ERROR());
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->status(Apache2::Const::SERVER_ERROR());
+ $r->content_type("text/plain; charset=utf-8");
$r->print($error."\015\012") unless $r->header_only;
- return Apache::Constants::SERVER_ERROR();
+ return Apache2::Const::SERVER_ERROR();
}
if (!defined $status)
{
- $r->status(Apache::Constants::NOT_FOUND());
- return Apache::Constants::NOT_FOUND();
+ $r->status(Apache2::Const::NOT_FOUND());
+ return Apache2::Const::NOT_FOUND();
}
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub serve_from_db
@@ -152,7 +152,7 @@
};
send_response($r, $printer);
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
my $ar;
@@ -179,7 +179,7 @@
};
send_response($r, $printer);
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub print_xml
@@ -199,10 +199,11 @@
# URLs are of the form:
# http://server/ws/1/puid/?name=<user_name>&client=<client id>&puids=<trackid:puid+trackid:puid>
- my $apr = Apache::Request->new($r);
+ my %args = $r->parse_args($r->args);;
my $user = $r->user;
- my @pairs = $apr->param('puid');
- my $client = $apr->param('client');
+ # FIXME needs something that handles multiple args of the same name
+ my @pairs = $args{'puid'};
+ my $client = $args{'client'};
my @puids;
foreach my $pair (@pairs)
@@ -210,8 +211,8 @@
my ($trackid, $puid) = split(' ', $pair);
if (!MusicBrainz::Server::Validation::IsGUID($puid) || !MusicBrainz::Server::Validation::IsGUID($trackid))
{
- $r->status(BAD_REQUEST);
- return BAD_REQUEST;
+ $r->status(HTTP_BAD_REQUEST);
+ return HTTP_BAD_REQUEST;
}
push @puids, { puid => $puid, trackmbid => $trackid };
}
@@ -234,8 +235,8 @@
# Ensure that we're not a replicated server and that we were given a client version
if (&DBDefs::REPLICATION_TYPE == &DBDefs::RT_SLAVE || $client eq '')
{
- $r->status(BAD_REQUEST);
- return BAD_REQUEST;
+ $r->status(HTTP_BAD_REQUEST);
+ return HTTP_BAD_REQUEST;
}
my $status = eval
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/User.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/User.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/1/User.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,8 +27,8 @@
package MusicBrainz::Server::Handlers::WS::1::User;
-use Apache::Constants qw( OK AUTH_REQUIRED SERVER_ERROR NOT_FOUND FORBIDDEN);
-use Apache::File ();
+use Apache2::Const qw( OK AUTH_REQUIRED SERVER_ERROR NOT_FOUND FORBIDDEN);
+use Apache2::compat qw( );
use MusicBrainz::Server::Handlers::WS::1::Common;
use Data::Dumper;
@@ -42,7 +42,7 @@
return bad_req($r, "Only GET is acceptable")
unless $r->method eq "GET";
- my %args; { no warnings; %args = $r->args };
+ my %args = $r->parse_args($r->args);;
my $user = $args{name};
# Ensure that the login name is the same as the resource requested
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/Private/Lookup.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/Private/Lookup.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers/WS/Private/Lookup.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,8 +27,8 @@
package MusicBrainz::Server::Handlers::WS::Private::Lookup;
-use Apache::Constants qw( );
-use Apache::File ();
+use Apache2::Const qw( );
+use Apache2::compat qw( );
use JSON;
sub handler
@@ -45,7 +45,7 @@
return bad_req($r, "uri contains extra components")
unless $r->uri eq "/ws/priv/lookup";
- my %args; { no warnings; %args = $r->args };
+ my %args = $r->parse_args($r->args);;
# extract the arguments from the args hash.
my $entitytype = $args{"entitytype"};
@@ -78,23 +78,23 @@
# if ($@)
# {
# my $error = "$@";
-# $r->status(Apache::Constants::SERVER_ERROR());
-# $r->send_http_header("text/plain; charset=utf-8");
+# $r->status(Apache2::Const::SERVER_ERROR());
+# $r->content_type("text/plain; charset=utf-8");
# $r->print($error."\015\012") unless $r->header_only;
-# return Apache::Constants::OK();
+# return Apache2::Const::OK();
# }
#
# # Damn.
-# return Apache::Constants::SERVER_ERROR();
+# return Apache2::Const::SERVER_ERROR();
}
sub bad_req
{
my ($r, $error) = @_;
- $r->status(Apache::Constants::BAD_REQUEST());
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->status(Apache2::Const::HTTP_BAD_REQUEST());
+ $r->content_type("text/plain; charset=utf-8");
$r->print($error."\015\012") unless $r->header_only;
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
sub serve_from_db
@@ -219,11 +219,11 @@
# the content type should be application/json, but
# Opera 8 can't handle that :(
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->content_type("text/plain; charset=utf-8");
$r->set_content_length(length($js));
$r->print($js) unless $r->header_only;
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
1;
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Handlers.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -27,7 +27,8 @@
package MusicBrainz::Server::Handlers;
-use Apache::Constants qw( DECLINED HTTP_NOT_ACCEPTABLE );
+use Apache2::Const qw( DECLINED HTTP_NOT_ACCEPTABLE );
+use Apache2::SubRequest ();
use HTTP::Headers;
use HTTP::Negotiate;
@@ -258,12 +259,14 @@
################################################################################
+use Apache2::Connection;
+
sub track_mb_taggers
{
my ($r) = @_;
require MusicBrainz::Server::Cache;
- my $key = "istagger-" . $r->connection->remote_ip;
+ my $key = "istagger-" . $r->connection->remote_ip();
my $is_tagger;
# See http://wiki.musicbrainz.org/ServerAccessPaths?highlight=mbt=1
@@ -280,13 +283,13 @@
sub LogHandler
{
my ($r) = @_;
- return &Apache::Constants::DECLINED unless $r->is_main;
+ return &Apache2::Const::DECLINED unless $r->is_main;
# Reset any overridden db, just to make sure
$MusicBrainz::db = undef;
eval {auto_detect_taggers($r) };
- return &Apache::Constants::DECLINED;
+ return &Apache2::Const::DECLINED;
}
sub auto_detect_taggers
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/LogFile.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/LogFile.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/LogFile.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -36,9 +36,7 @@
);
}
-use Apache ();
-use Apache::File ();
-use Apache::Table ();
+#use Apache2::File ();
use Fcntl qw( LOCK_EX LOCK_UN );
our %logfiles;
@@ -55,18 +53,18 @@
{
my ($key, $path) = $spec =~ /^(\w+)=(.*)$/
or do {
- Apache::warn("Ignoring malformed MBLogFile value '$spec'");
+ Apache2::warn("Ignoring malformed MBLogFile value '$spec'");
next;
};
$logfiles{$key} = undef, next
if $path eq "/dev/null";
- $path = Apache->server_root_relative($path);
+ $path = Apache22->ServerUtil->server_root_relative($path);
- my $fh = Apache::File->new(">>$path")
+ my $fh = Apache2::File->new(">>$path")
or do {
- Apache::warn("Error opening $path: $!");
+ Apache2::warn("Error opening $path: $!");
next;
};
{ my $o = select $fh; $| = 1; select $o }
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Mason.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Mason.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/Mason.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -30,7 +30,8 @@
package MusicBrainz::Server::Mason;
-use Apache::Constants qw( DECLINED NOT_FOUND );
+use Apache2::Const qw/OK NOT_FOUND/;
+use Apache2::ServerUtil;
sub preload_files
{
@@ -115,11 +116,11 @@
# out. And |u on its own is usually the wrong thing to do.
$handler->interp->remove_escape('u');
- my $u = Apache->server->uid;
- my $g = Apache->server->gid;
+ my $u = 0;#Apache2::ServerUtil->user_id;
+ my $g = 0;#Apache2::ServerUtil->group_id;
- if (($> != $u or $) != $g) and ($>==0 or $<==0))
- {
+ #if (($> != $u or $) != $g) and ($>==0 or $<==0))
+ #{
# Running as root? "chown" MASON_DIR to the Apache user and group
# we're going to be serving requests under.
# Mason claims to do this itself, but it doesn't seem to work :-(
@@ -127,8 +128,8 @@
# This used to be done all in-process using File::Find; but doing it
# this way is actually more efficient, because then we don't have to
# bloat ourselves up with File::Find.
- system "chown", "-R", "$u:$g", &DBDefs::MASON_DIR;
- }
+ # system "chown", "-R", "$u:$g", &DBDefs::MASON_DIR;
+ #}
$handler;
}
@@ -141,12 +142,12 @@
{
my $uri = $r->uri;
- return NOT_FOUND if $uri =~ m[/comp/];
- return NOT_FOUND if $uri =~ /\.inc$/;
+ return Apache2::Const::NOT_FOUND if $uri =~ m[/comp/];
+ return Apache2::Const::NOT_FOUND if $uri =~ /\.inc$/;
}
- return DECLINED if (!defined $r->content_type);
- return DECLINED if $r->content_type && $r->content_type !~ m[^text/html\b]io;
+ return Apache2::Const::DECLINED if (!defined $r->content_type);
+ return Apache2::Const::DECLINED if $r->content_type && $r->content_type !~ m[^text/html\b]io;
package MusicBrainz::Server::ComponentPackage;
@@ -161,13 +162,15 @@
%pnotes = ();
%cookies = ();
- {
- my $req = Apache::Request->instance($r);
- $pnotes{'ispopup'} = ($req->param("ispopup") ? 1 : "");
- }
+ my $req = $r;
+ # FIXME
+ #{
+ # my $req = Apache2::Request->instance($r);
+ # $pnotes{'ispopup'} = ($req->param("ispopup") ? 1 : "");
+ #}
use CGI::Cookie ();
- %cookies = CGI::Cookie->parse($r->header_in('Cookie'));
+ %cookies = CGI::Cookie->parse($r->headers_in->{Cookie});
$_ = $_->value for values %cookies;
my $tied = undef;
@@ -219,7 +222,7 @@
if (defined $user and $user ne "")
{
use URI::Escape qw( uri_escape );
- $r->connection->user(uri_escape($user, '^A-Za-z0-9._-'));
+ $r->user(uri_escape($user, '^A-Za-z0-9._-'));
}
$tied = undef;
@@ -242,15 +245,15 @@
sub rate_limited
{
my ($r, $t) = @_;
- $r->status(Apache::Constants::HTTP_SERVICE_UNAVAILABLE());
+ $r->status(Apache2::Const::HTTP_SERVICE_UNAVAILABLE());
$r->headers_out->add("X-Rate-Limited", sprintf("%.1f %.1f %d", $t->rate, $t->limit, $t->period));
- $r->send_http_header("text/plain; charset=utf-8");
+ $r->content_type("text/plain; charset=utf-8");
unless ($r->header_only)
{
$r->print("Your requests are exceeding the allowable rate limit (" . $t->msg . ")\015\012");
$r->print("Please slow down then try again.\015\012");
}
- return Apache::Constants::OK();
+ return Apache2::Const::OK();
}
# Given a key (optional - defaults to something sensible), tests to see if the
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/TRMGatewayHandler.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/TRMGatewayHandler.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz/Server/TRMGatewayHandler.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -29,7 +29,7 @@
use MusicBrainz::Server::TRMGateway;
use MusicBrainz::Server::LogFile qw( lprint lprintf );
-use Apache::Constants qw( :http M_POST OK );
+use Apache2::Const qw( :http M_POST OK );
use Time::HiRes qw( gettimeofday tv_interval );
use constant REQ_CONTENT_TYPE => "application/octet-stream";
@@ -72,7 +72,7 @@
{
lprint "TRMGatewayHandler", "Sigserver disconnect request discarded";
$r->status(HTTP_OK);
- $r->send_http_header(RESP_CONTENT_TYPE);
+ $r->content_type(RESP_CONTENT_TYPE);
# No body
OK;
}
@@ -92,7 +92,7 @@
if $r->dir_config('WarnIfSigserverDisabled');
if ($memc) { $memc->add("trm-disabled", 0); $memc->incr("trm-disabled", 1); }
$r->status(HTTP_SERVICE_UNAVAILABLE);
- $r->send_http_header;
+ $r->content_type;
return OK;
}
@@ -111,7 +111,7 @@
lprint "TRMGatewayHandler", "Too many sigservers ($newcount > $MAX_SIGSERVERS)"
if $r->dir_config('WarnIfSigserverBusy');
$r->status(HTTP_SERVICE_UNAVAILABLE);
- $r->send_http_header;
+ $r->content_type;
return OK;
}
@@ -127,7 +127,7 @@
if ($memc) { $memc->add("trm-nogateway", 0); $memc->incr("trm-nogateway", 1); }
lprint "TRMGatewayHandler", "Couldn't get gateway object";
$r->status(HTTP_SERVICE_UNAVAILABLE);
- $r->send_http_header;
+ $r->content_type;
return OK;
}
@@ -159,7 +159,7 @@
lprint "sigserver", "sigserver timed out"
if $COLLECT_STATS;
$r->status(HTTP_SERVICE_UNAVAILABLE);
- $r->send_http_header;
+ $r->content_type;
return OK;
}
@@ -170,7 +170,7 @@
remove_gateway();
if ($memc) { $memc->add("trm-error", 0); $memc->incr("trm-error", 1); }
$r->status(HTTP_SERVICE_UNAVAILABLE);
- $r->send_http_header;
+ $r->content_type;
return OK;
}
@@ -188,7 +188,7 @@
}
$r->status(HTTP_OK);
- $r->send_http_header(RESP_CONTENT_TYPE);
+ $r->content_type(RESP_CONTENT_TYPE);
$r->print($bytes);
if ($r->dir_config("LogTrmAnswers"))
@@ -211,7 +211,7 @@
my $r = shift;
my $msg = shift;
$r->status(HTTP_INTERNAL_SERVER_ERROR);
- $r->send_http_header("text/plain");
+ $r->content_type("text/plain");
$r->print($msg || "Unspecified internal server error\n")
unless $r->header_only;
@@ -223,7 +223,7 @@
{
my $r = shift;
$r->status(HTTP_NOT_ACCEPTABLE);
- $r->send_http_header("text/plain");
+ $r->content_type("text/plain");
my $t = REQ_CONTENT_TYPE;
my $n = REQ_BODY_SIZE;
Modified: mb_server/branches/apache2/cgi-bin/MusicBrainz.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/MusicBrainz.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/MusicBrainz.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -58,7 +58,7 @@
{
$INC{'Apache.pm'} or last;
- my $r = eval{ Apache->request } or last;
+ my $r = eval{ Apache2::RequestUtil->request } or last;
$db = $r->dir_config->get("MBDatabase");
}
last if $db;
@@ -120,13 +120,13 @@
sub Logout
{
my ($this) = @_;
-
$this->{DBH}->disconnect() if ($this->{DBH});
}
sub DESTROY
{
- shift()->Logout;
+ # FIXME under under mod_perl2, this seems to be called too early
+ #shift()->Logout;
}
1;
Modified: mb_server/branches/apache2/cgi-bin/QuerySupport.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/QuerySupport.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/QuerySupport.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -685,7 +685,7 @@
$tracknum, $duration, $filename)=@_;
my ($sql, @ids, $query);
- my $ip = eval { Apache->request->connection->remote_ip } || "?";
+ my $ip = eval { Apache2::RequestUtil->request->connection->remote_ip } || "?";
lprint "trmlookup", "begin trm=".($id||'')." ip=$ip";
return $rdf->ErrorRDF("No trm id given.")
@@ -727,7 +727,7 @@
my $selmode;
- if (my $r = Apache->request)
+ if (my $r = Apache2::RequestUtil->request)
{
if ($r->pnotes("is-mbtagger") and $r->the_request =~ m/^POST \/mm-2.1\//)
{
Modified: mb_server/branches/apache2/cgi-bin/UserStuff.pm
===================================================================
--- mb_server/branches/apache2/cgi-bin/UserStuff.pm 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/UserStuff.pm 2008-03-08 20:43:11 UTC (rev 9720)
@@ -31,7 +31,7 @@
use strict;
use DBDefs;
use MusicBrainz::Server::Validation;
-use Apache;
+use Apache2::RequestUtil;
use URI::Escape qw( uri_escape );
use CGI::Cookie;
use Digest::SHA1 qw(sha1_base64);
@@ -1125,7 +1125,7 @@
-domain => &DBDefs::SESSION_DOMAIN,
);
- my $r = Apache->request;
+ my $r = Apache2::RequestUtil->request;
$r->headers_out->add('Set-Cookie' => $cookie);
}
@@ -1152,7 +1152,7 @@
-domain => &DBDefs::SESSION_DOMAIN,
);
- my $r = Apache->request;
+ my $r = Apache2::RequestUtil->request;
$r->headers_out->add('Set-Cookie' => $cookie);
}
@@ -1187,7 +1187,7 @@
sub SetPermanentCookie
{
my ($this, %opts) = @_;
- my $r = Apache->request;
+ my $r = Apache2::RequestUtil->request;
my ($username, $password) = ($this->GetName, $this->GetPassword);
@@ -1218,7 +1218,7 @@
sub ClearPermanentCookie
{
- my $r = Apache->request;
+ my $r = Apache2::RequestUtil->request;
my $cookie = new CGI::Cookie(
-name => &PERMANENT_COOKIE_NAME,
@@ -1245,7 +1245,7 @@
my $session = GetSession();
return if $session->{uid};
- my $r = Apache->request;
+ my $r = Apache2::RequestUtil->request;
# Get the permanent cookie
my $c = $cookies->{&PERMANENT_COOKIE_NAME}
Modified: mb_server/branches/apache2/cgi-bin/mq.pl
===================================================================
--- mb_server/branches/apache2/cgi-bin/mq.pl 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/mq.pl 2008-03-08 20:43:11 UTC (rev 9720)
@@ -266,7 +266,7 @@
$rdf->SetBaseURI("http://" . $ENV{SERVER_NAME});
if (exists $ENV{"MOD_PERL"})
{
- $r = Apache->request();
+ $r = Apache2::RequestUtil->request();
my $size = $r->header_in("Content-length");
$r->read($rdfinput, $size);
}
Modified: mb_server/branches/apache2/cgi-bin/mq_2_1.pl
===================================================================
--- mb_server/branches/apache2/cgi-bin/mq_2_1.pl 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/mq_2_1.pl 2008-03-08 20:43:11 UTC (rev 9720)
@@ -208,7 +208,7 @@
$rdf->SetBaseURI("http://" . $ENV{SERVER_NAME} . "/mm-2.1");
if (exists $ENV{"MOD_PERL"})
{
- $r = Apache->request();
+ $r = Apache2::RequestUtil->request();
my $size = $r->header_in("Content-length");
$r->read($rdfinput, $size);
}
Modified: mb_server/branches/apache2/cgi-bin/rdf.pl
===================================================================
--- mb_server/branches/apache2/cgi-bin/rdf.pl 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/rdf.pl 2008-03-08 20:43:11 UTC (rev 9720)
@@ -50,7 +50,7 @@
{
my $apr;
- $r = Apache->request();
+ $r = Apache2::RequestUtil->request();
$apr = Apache::Request->new($r);
$id = $apr->param('id');
$query = $apr->param('query');
Modified: mb_server/branches/apache2/cgi-bin/rdf_2_1.pl
===================================================================
--- mb_server/branches/apache2/cgi-bin/rdf_2_1.pl 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/cgi-bin/rdf_2_1.pl 2008-03-08 20:43:11 UTC (rev 9720)
@@ -54,7 +54,7 @@
{
my $apr;
- $r = Apache->request();
+ $r = Apache2::RequestUtil->request();
$apr = Apache::Request->new($r);
$id = $apr->param('id');
$query = $apr->param('query');
Modified: mb_server/branches/apache2/htdocs/comp/redirect
===================================================================
--- mb_server/branches/apache2/htdocs/comp/redirect 2008-03-08 20:32:08 UTC (rev 9719)
+++ mb_server/branches/apache2/htdocs/comp/redirect 2008-03-08 20:43:11 UTC (rev 9720)
@@ -1,13 +1,13 @@
<%perl>
my ($url) = @_;
- my $host = $r->header_in("Host") || &DBDefs::WEB_SERVER;
+ my $host = $r->headers_in->{Host} || &DBDefs::WEB_SERVER;
$url = "http://" . $host . $url
unless $url =~ /^\w+:/;
$r->status(303);
- $r->header_out(Location => $url);
+ $r->headers_out->{Location} = $url;
$m->abort;
More information about the MusicBrainz-commits
mailing list