fixed HTTP bugs
This commit is contained in:
parent
3248a01b2f
commit
3ce8565a4f
4 changed files with 61 additions and 36 deletions
|
|
@ -6,6 +6,10 @@
|
||||||
- Fixed a bug in the URL checker javascript that wouldn't allow for relative
|
- Fixed a bug in the URL checker javascript that wouldn't allow for relative
|
||||||
paths.
|
paths.
|
||||||
- bugfix [ 991205 ] 6.0.3 Data Form data field sequence problem (Steven Chan)
|
- bugfix [ 991205 ] 6.0.3 Data Form data field sequence problem (Steven Chan)
|
||||||
|
- bugfix [ 1028498 ] Problem with page link in navigation
|
||||||
|
- bugfix [ 1031411 ] FileCache Problem since V6.2.x
|
||||||
|
- Fixed a problem with HTTP codes being spewed into the page content on codes
|
||||||
|
other than 200.
|
||||||
|
|
||||||
6.2.3
|
6.2.3
|
||||||
- Changed to new POD format.
|
- Changed to new POD format.
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,6 @@ sub page {
|
||||||
my $output = _processOperations();
|
my $output = _processOperations();
|
||||||
if ($output ne "") {
|
if ($output ne "") {
|
||||||
$output = _generatePage($output);
|
$output = _generatePage($output);
|
||||||
$output = WebGUI::HTTP::getHeader().$output;
|
|
||||||
} else {
|
} else {
|
||||||
my $useCache = (
|
my $useCache = (
|
||||||
$session{form}{op} eq "" &&
|
$session{form}{op} eq "" &&
|
||||||
|
|
@ -154,12 +153,12 @@ sub page {
|
||||||
} else {
|
} else {
|
||||||
$ttl = $session{page}{cacheTimeout};
|
$ttl = $session{page}{cacheTimeout};
|
||||||
}
|
}
|
||||||
$output = WebGUI::HTTP::getHeader().$output;
|
$cache->set($output, $ttl) if ($useCache && !WebGUI::HTTP::isRedirect());
|
||||||
$cache->set($output, $ttl) if ($useCache);
|
|
||||||
WebGUI::PassiveProfiling::addPage(); # add wobjects on page to passive profile log
|
WebGUI::PassiveProfiling::addPage(); # add wobjects on page to passive profile log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WebGUI::Affiliate::grabReferral(); # process affilliate tracking request
|
WebGUI::Affiliate::grabReferral(); # process affilliate tracking request
|
||||||
|
$output = WebGUI::HTTP::getHeader().$output;
|
||||||
# This allows an operation or wobject to write directly to the browser.
|
# This allows an operation or wobject to write directly to the browser.
|
||||||
$output = undef if ($session{page}{empty});
|
$output = undef if ($session{page}{empty});
|
||||||
WebGUI::Session::close() unless ($useExistingSession);
|
WebGUI::Session::close() unless ($useExistingSession);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ use WebGUI::HTTP;
|
||||||
WebGUI::HTTP::setRedirect($url);
|
WebGUI::HTTP::setRedirect($url);
|
||||||
WebGUI::HTTP::setCookie($name,$value);
|
WebGUI::HTTP::setCookie($name,$value);
|
||||||
WebGUI::HTTP::setNoHeader($bool);
|
WebGUI::HTTP::setNoHeader($bool);
|
||||||
|
|
||||||
|
$mimetype = WebGUI::HTTP::getMimeType();
|
||||||
|
$code = WebGUI::HTTP::getStatus();
|
||||||
|
$boolean = WebGUI::HTTP::isRedirect();
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
|
|
@ -53,33 +57,34 @@ Generates an HTTP header.
|
||||||
|
|
||||||
sub getHeader {
|
sub getHeader {
|
||||||
return undef if ($session{http}{noHeader});
|
return undef if ($session{http}{noHeader});
|
||||||
my $header;
|
my %params;
|
||||||
unless (exists $session{http}{location}) {
|
if (isRedirect()) {
|
||||||
unless ($session{http}{charset}) {
|
%params = (
|
||||||
$session{http}{charset} = WebGUI::International::getLanguage($session{page}{languageId},"charset") || "ISO-8859-1";
|
-location => $session{http}{location}
|
||||||
}
|
|
||||||
unless ($session{http}{mimetype}) {
|
|
||||||
$session{http}{mimetype} = "text/html";
|
|
||||||
}
|
|
||||||
if ($session{setting}{preventProxyCache}) {
|
|
||||||
$session{http}{expires} = "-1d";
|
|
||||||
}
|
|
||||||
$header = $session{cgi}->header(
|
|
||||||
-type => $session{http}{mimetype},
|
|
||||||
-charset => $session{http}{charset},
|
|
||||||
-cookie => $session{http}{cookie},
|
|
||||||
-status => $session{http}{status},
|
|
||||||
-attachment => $session{http}{filename},
|
|
||||||
-expires => $session{http}{expires}
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$header = $session{cgi}->header(
|
%params = (
|
||||||
-cookie => $session{http}{cookie},
|
-type => $session{http}{mimetype} || "text/html",
|
||||||
-location => $session{http}{location},
|
-charset => $session{http}{charset} || WebGUI::International::getLanguage($session{page}{languageId},"charset") || "UTF-8"
|
||||||
-status => $session{http}{status}
|
|
||||||
);
|
);
|
||||||
|
if ($session{setting}{preventProxyCache}) {
|
||||||
|
$params{"-expires"} = "-1d";
|
||||||
|
}
|
||||||
|
if ($session{http}{filename}) {
|
||||||
|
$params{"-attachment"} => $session{http}{filename};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $header;
|
$params{"-cookie"} = $session{http}{cookie};
|
||||||
|
if($session{env}{MOD_PERL}) {
|
||||||
|
my $r = Apache->request;
|
||||||
|
if(defined($r)) {
|
||||||
|
$r->custom_response($session{http}{status}, '<!-- '.$session{http}{statusDescription}.' -->' );
|
||||||
|
$r->status($session{http}{status});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$params{"-status"} = $session{http}{status}.' '.$session{http}{statusDescription};
|
||||||
|
}
|
||||||
|
return $session{cgi}->header(%params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,10 +110,22 @@ Returns the current HTTP status code, if one has been set.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub getStatus {
|
sub getStatus {
|
||||||
return $session{http}{status} || "200 OK";
|
return $session{http}{status} || "200";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 isRedirect ( )
|
||||||
|
|
||||||
|
Returns a boolean value indicating whether the current page will redirect to some other location.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub isRedirect {
|
||||||
|
return (getStatus() eq "302");
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 setCookie ( name, value [ , timeToLive ] )
|
=head2 setCookie ( name, value [ , timeToLive ] )
|
||||||
|
|
@ -215,24 +232,29 @@ The URL to redirect to.
|
||||||
|
|
||||||
sub setRedirect {
|
sub setRedirect {
|
||||||
$session{http}{location} = shift;
|
$session{http}{location} = shift;
|
||||||
setStatus("302 Redirect");
|
setStatus("302", "Redirect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 setStatus ( status )
|
=head2 setStatus ( code, description )
|
||||||
|
|
||||||
Sets the HTTP status code.
|
Sets the HTTP status code.
|
||||||
|
|
||||||
=head3 status
|
=head3 code
|
||||||
|
|
||||||
An HTTP status code. It takes the form of "NNN Message" where NNN is a 3 digit status number and Message is some text explaining the status number.
|
An HTTP status code. It is a 3 digit status number.
|
||||||
|
|
||||||
|
=head3 description
|
||||||
|
|
||||||
|
An HTTP status code description. It is a little one line of text that describes the status code.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub setStatus {
|
sub setStatus {
|
||||||
$session{http}{status} = shift;
|
$session{http}{status} = shift;
|
||||||
|
$session{http}{statusDescription} = shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ Returns a message stating that this functionality can only be used by administra
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub adminOnly {
|
sub adminOnly {
|
||||||
WebGUI::HTTP::setStatus("401 Admin Only");
|
WebGUI::HTTP::setStatus("401", "Admin Only");
|
||||||
my ($output, $sth, @data);
|
my ($output, $sth, @data);
|
||||||
$output = '<h1>'.WebGUI::International::get(35).'</h1>';
|
$output = '<h1>'.WebGUI::International::get(35).'</h1>';
|
||||||
$output .= WebGUI::International::get(36);
|
$output .= WebGUI::International::get(36);
|
||||||
|
|
@ -68,7 +68,7 @@ Returns a message stating that the user does not have the required privileges to
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub insufficient {
|
sub insufficient {
|
||||||
WebGUI::HTTP::setStatus("401 Insufficient Privileges");
|
WebGUI::HTTP::setStatus("401", "Insufficient Privileges");
|
||||||
my ($output);
|
my ($output);
|
||||||
$output = '<h1>'.WebGUI::International::get(37).'</h1>';
|
$output = '<h1>'.WebGUI::International::get(37).'</h1>';
|
||||||
$output .= WebGUI::International::get(38);
|
$output .= WebGUI::International::get(38);
|
||||||
|
|
@ -86,7 +86,7 @@ Returns a message stating that the user does not have the privileges necessary t
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub noAccess {
|
sub noAccess {
|
||||||
WebGUI::HTTP::setStatus("401 No Access");
|
WebGUI::HTTP::setStatus("401", "No Access");
|
||||||
my ($output);
|
my ($output);
|
||||||
if ($session{user}{userId} <= 1) {
|
if ($session{user}{userId} <= 1) {
|
||||||
$output = WebGUI::Operation::Auth::www_auth("init");
|
$output = WebGUI::Operation::Auth::www_auth("init");
|
||||||
|
|
@ -107,7 +107,7 @@ Returns a message stating that the user they requested information about is no l
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub notMember {
|
sub notMember {
|
||||||
WebGUI::HTTP::setStatus("400 Not A Member");
|
WebGUI::HTTP::setStatus("400", "Not A Member");
|
||||||
my ($output);
|
my ($output);
|
||||||
$output = '<h1>'.WebGUI::International::get(345).'</h1>';
|
$output = '<h1>'.WebGUI::International::get(345).'</h1>';
|
||||||
$output .= WebGUI::International::get(346);
|
$output .= WebGUI::International::get(346);
|
||||||
|
|
@ -124,7 +124,7 @@ Returns a message stating that the user made a request to delete something that
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub vitalComponent {
|
sub vitalComponent {
|
||||||
WebGUI::HTTP::setStatus("403 Vital Component");
|
WebGUI::HTTP::setStatus("403", "Vital Component");
|
||||||
my ($output);
|
my ($output);
|
||||||
$output = '<h1>'.WebGUI::International::get(40).'</h1>';
|
$output = '<h1>'.WebGUI::International::get(40).'</h1>';
|
||||||
$output .= WebGUI::International::get(41);
|
$output .= WebGUI::International::get(41);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue