Skip to content

Commit

Permalink
Item11808: perltidy them all, so people are not accidentally impacted…
Browse files Browse the repository at this point in the history
… by the new enforced rule -- Sorry Micha, could not find a way to define specific values within the file

git-svn-id: http://svn.foswiki.org/trunk/HTTPEngineContrib@14686 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed May 4, 2012
1 parent 7c1c194 commit e3ea26b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
6 changes: 4 additions & 2 deletions lib/Foswiki/Contrib/HTTPEngineContrib.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ use strict;

use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION );

$VERSION = '$Rev$'; # version of *this file*.
$VERSION = '$Rev$'; # version of *this file*.

# This is *not* the version of the package, which should be set in the
# | Version: | line in the extension topic.

$SHORTDESCRIPTION = 'Make it possible to run Foswiki as a standalone web server';
$SHORTDESCRIPTION =
'Make it possible to run Foswiki as a standalone web server';

6 changes: 3 additions & 3 deletions lib/Foswiki/Engine/HTTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use Foswiki::Engine ();

use strict;

use Foswiki::Request ();
use Foswiki::Request::Upload ();
use Foswiki::Response ();
use Foswiki::Request ();
use Foswiki::Request::Upload ();
use Foswiki::Response ();

my $CRLF = "\x0D\x0A";

Expand Down
21 changes: 11 additions & 10 deletions lib/Foswiki/Engine/HTTP/CGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ sub manageInteraction {
$_->blocking(0) foreach @_;

my ( $inref, $outref, $error, $cgiState, $cgiBodyLeft, $done );
$inref = $this->{input_ref};
$outref = \'';
$inref = $this->{input_ref};
$outref = \'';
$cgiState = 'headers';
$done = 0;
$done = 0;
my $clBodyLeft = -length($$inref);
$clBodyLeft += $this->{headers}->content_length
if $this->{headers}->content_length;
Expand Down Expand Up @@ -184,22 +184,23 @@ sub manageInteraction {
$rv = $cgih->add($outref);
if ($rv) {
my $res = HTTP::Response->new();
if ($cgih->headers->content_type) {
if ( $cgih->headers->content_type ) {
$res->code(200);
$res->headers($cgih->headers);
$res->headers( $cgih->headers );
$$outref = $res->as_string . $$outref;
}
elsif ($cgih->headers->header('Location')) {
elsif ( $cgih->headers->header('Location') ) {
$res->code(302);
$res->headers($cgih->headers);
$res->headers( $cgih->headers );
$$outref = $res->as_string . $$outref;
}
elsif ($cgih->headers->header('Status')) {
$res->code($cgih->hedaers->header('Status'));
$res->headers($cgih->headers);
elsif ( $cgih->headers->header('Status') ) {
$res->code( $cgih->hedaers->header('Status') );
$res->headers( $cgih->headers );
$$outref = $res->as_string . $$outref;
}
else {

# Error 500
}
}
Expand Down
28 changes: 12 additions & 16 deletions lib/Foswiki/Engine/HTTP/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,9 @@ sub default_values {
$opts->{puburlpath} = '/pub';
$opts->{scripturlpath} = '/bin';
$opts->{pubdir} = Cwd::abs_path(
File::Spec->catdir(
File::Basename::dirname( $0 ),
qw(.. pub)
)
);
File::Spec->catdir( File::Basename::dirname($0), qw(.. pub) ) );
$opts->{scriptdir} = Cwd::abs_path(
File::Spec->catdir(
File::Basename::dirname( $0 ),
qw(.. bin)
)
);
File::Spec->catdir( File::Basename::dirname($0), qw(.. bin) ) );
return $opts;
}

Expand All @@ -102,7 +94,8 @@ sub process_request {
};

unless ( defined $method && $method =~ /(?:POST|GET|HEAD)/i ) {
Foswiki::Engine::HTTP::Util::sendResponse($this->{server}{client}, 501);
Foswiki::Engine::HTTP::Util::sendResponse( $this->{server}{client},
501 );
return;
}

Expand All @@ -113,7 +106,8 @@ sub process_request {
$proto = $1;
}
else {
Foswiki::Engine::HTTP::Util::sendResponse($this->{server}{client}, 505);
Foswiki::Engine::HTTP::Util::sendResponse( $this->{server}{client},
505 );
return;
}

Expand Down Expand Up @@ -142,7 +136,8 @@ sub process_request {
$path_info =~ s/%(..)/chr(hex($1))/ge;

unless ( defined $action ) {
Foswiki::Engine::HTTP::Util::sendResponse($this->{server}{client}, 403);
Foswiki::Engine::HTTP::Util::sendResponse( $this->{server}{client},
403 );
return; # Abort the connection
}

Expand All @@ -159,8 +154,8 @@ sub process_request {
$handler = 'CGI';
push @args,
(
scriptdir => $this->{server}{scriptdir},
opts => $this->{server},
scriptdir => $this->{server}{scriptdir},
opts => $this->{server},
);
}
else {
Expand Down Expand Up @@ -190,7 +185,8 @@ sub process_request {
$worker->finish();
}
else {
Foswiki::Engine::HTTP::Util::sendResponse($this->{server}{client}, 404);
Foswiki::Engine::HTTP::Util::sendResponse( $this->{server}{client},
404 );
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Foswiki/Engine/HTTP/Static.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ sub send_response {
$this->_translateUri();
if ( -e $this->{file} && -r _ && !-d _ ) {
my ( $size, $mtime ) = ( stat(_) )[ 7, 9 ];

guess_media_type( $this->{file}, $headers );

my $lmtime = str2time( $this->{headers}->header('If-Modified-Since') );
if ( $this->{method} eq 'GET' && $lmtime && $mtime <= $lmtime ) {
$this->_write( $sock, 304, $headers );
return 304;
}

$headers->header( 'Last-Modified' => time2str($mtime) );
$headers->content_length($size);
$headers->header( Connection => 'close' )
Expand Down
7 changes: 3 additions & 4 deletions lib/Foswiki/Engine/HTTP/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use Error qw(:try);
use Time::HiRes qw(time);
use Errno qw(EINTR EWOULDBLOCK EAGAIN);


sub readHeader {
my ( $fd, $opts, $full ) = @_;
my $sel = IO::Select->new($fd);
Expand Down Expand Up @@ -101,10 +100,10 @@ sub readBody {

my $body = HTTP::Body->new( $headers->header('Content-Type'),
$headers->content_length );
$body->add( $$input_ref );
my $bytes_read = length( $$input_ref );
$body->add($$input_ref);
my $bytes_read = length($$input_ref);

my $sel = IO::Select->new( $fd );
my $sel = IO::Select->new($fd);

while ( $bytes_read < $headers->content_length && $timeleft >= 0 ) {
my $now = time;
Expand Down

0 comments on commit e3ea26b

Please sign in to comment.