[interchange-cvs] interchange - heins modified lib/Vend/Server.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Sun Aug 11 11:45:01 2002
User: heins
Date: 2002-08-11 15:44:10 GMT
Modified: lib/Vend Server.pm
Log:
* Remove internal HTTP server completely from Interchange 4.9.
Revision Changes Path
2.10 +4 -124 interchange/lib/Vend/Server.pm
rev 2.10, prev_rev 2.9
Index: Server.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Server.pm,v
retrieving revision 2.9
retrieving revision 2.10
diff -u -r2.9 -r2.10
--- Server.pm 19 Jul 2002 05:13:16 -0000 2.9
+++ Server.pm 11 Aug 2002 15:44:10 -0000 2.10
@@ -1,6 +1,6 @@
# Vend::Server - Listen for Interchange CGI requests as a background server
#
-# $Id: Server.pm,v 2.9 2002/07/19 05:13:16 mheins Exp $
+# $Id: Server.pm,v 2.10 2002/08/11 15:44:10 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -25,7 +25,7 @@
package Vend::Server;
=20
use vars qw($VERSION);
-$VERSION =3D substr(q$Revision: 2.9 $, 10);
+$VERSION =3D substr(q$Revision: 2.10 $, 10);
=20
use POSIX qw(setsid strftime);
use Vend::Util;
@@ -600,8 +600,8 @@
/
);
};
-=09=09=09=09=09=09=09=09=09=09=20
-}=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20
+
+}
=20
sub http_log_msg {
my($status, $env, $request) =3D @_;
@@ -712,123 +712,6 @@
return $ref;
}
=20
-sub http_server {
- my($status_line, $in, $argv, $env, $entity) =3D @_;
-
- die "Need URI::URL for this functionality.\n"
- unless defined $HTTP_enabled;
-
- $Vend::InternalHTTP =3D 1;
- my ($header, $request, $block);
- my $waiting =3D 0;
- ($$env{REQUEST_METHOD},$request) =3D split /\s+/, $status_line;
- for(;;) {
- $block =3D _find(\$in, "\n");
-#::logDebug("read: $block");
- $block =3D~ s/\s+$//;
- if($block eq '') {
- last;
- }
- if ( $block =3D~ s/^([^:]+):\s*//) {
- $header =3D lc $1;
- if(defined $CGImap{$header}) {
- $$env{$CGImap{$header}} =3D $block;
- }
- next;
- }
- else {
- die "HTTP protocol error on '$block':\n$in";
- }
- last;
- }
-
- if ($$env{CONTENT_LENGTH}) {
- _read(\$in) while length($in) < $$env{CONTENT_LENGTH};
- }
- $in =3D~ s/\s+$//;
- $$entity =3D $in;
-
-#::logDebug("exiting loop");
- my $url =3D new URI::URL $request;
- @{$argv} =3D $url->keywords();
-
- (undef, $Remote_addr) =3D
- sockaddr_in(getpeername(MESSAGE));
- $$env{REMOTE_HOST} =3D gethostbyaddr($Remote_addr, AF_INET);
- $Remote_addr =3D inet_ntoa($Remote_addr);
-
- $$env{QUERY_STRING} =3D $url->equery();
- $$env{REMOTE_ADDR} =3D $Remote_addr;
-
- my (@path) =3D $url->path_components();
- my $path =3D $url->path();
- my $doc;
- my $status =3D 200;
-
- shift(@path);
- my $catname =3D shift(@path);
-
- if ($Global::TcpMap->{$Global::TcpPort} =3D~ /^\w+/) {
- $catname =3D $Global::TcpMap->{$Global::TcpPort};
- }
- my $cat =3D "/$catname";
-
- if($Global::Selector{$cat} and $Global::AllowGlobal->{$cat}) {
- if ($$env{AUTHORIZATION}) {
- $$env{REMOTE_USER} =3D
- Vend::Util::check_authorization( delete $$env{AUTHORIZATION} );
- }
- if (! $$env{REMOTE_USER}) {
- $Vend::StatusLine =3D <<EOF;
-HTTP/1.0 401 Unauthorized
-WWW-Authenticate: Basic realm=3D"Interchange Admin"
-EOF
- $doc =3D "Requires correct username and password.\n";
- $path =3D '';
- }
- }
-
- if($Global::Selector{$cat} || $Global::SelectorAlias{$cat}) {
- $$env{SCRIPT_NAME} =3D $cat;
- $$env{PATH_INFO} =3D join "/", '', @path;
- }
- elsif(-f "$Global::VendRoot/doc$path") {
- $Vend::StatusLine =3D "HTTP/1.0 200 OK";
- $doc =3D readfile("$Global::VendRoot/doc$path");
- }
- else {
- $status =3D 404;
- $Vend::StatusLine =3D "HTTP/1.0 404 Not found";
- $doc =3D "$path not a Interchange catalog or help file.\n";
- }
-
- if($$env{REQUEST_METHOD} eq 'HEAD') {
- $Vend::StatusLine =3D "HTTP/1.0 200 OK\nLast-modified: "
- . Vend::Util::logtime;
- $doc =3D '';
- }
-
- logData("$Global::VendRoot/etc/access_log",
- http_log_msg(
- $status,
- $env,
- ($$env{REQUEST_METHOD} . " " . $request),
- )
- );
-
- if (defined $doc) {
- my $type =3D Vend::Util::mime_type($path);
- $Vend::StatusLine =3D '' unless defined $Vend::StatusLine;
- $Vend::StatusLine .=3D "\r\nContent-type: $type";
- respond(
- '',
- \$doc,
- );
- return;
- }
- return 1;
-}
-
sub read_cgi_data {
my ($argv, $env, $entity) =3D @_;
my ($in, $block, $n, $i, $e, $key, $value);
@@ -850,9 +733,6 @@
elsif ($block =3D~ m/^entity$/) {
$$entity =3D _string(\$in);
}
- elsif ($block =3D~ m/^[GPH]/) {
- return http_server($block, $in, @_);
- }
elsif (($n) =3D ($block =3D~ m/^arg (\d+)$/)) {
$#$argv =3D $n - 1;
foreach $i (0 .. $n - 1) {