Turned on Debug middleware
Removed unnecessary $session->close() now that we have WebGUI::Middleware::Session Fixed Content-Type bug
This commit is contained in:
parent
10e8d1898d
commit
f22020c267
7 changed files with 6 additions and 19 deletions
1
TODO
1
TODO
|
|
@ -8,6 +8,7 @@ DONE
|
||||||
* WebGUI::authen API changed
|
* WebGUI::authen API changed
|
||||||
* urlHandler API changed - no longer gets server, config
|
* urlHandler API changed - no longer gets server, config
|
||||||
* Streaming response body
|
* Streaming response body
|
||||||
|
* Delete lib/WebGUI/URL and replace with new Middleware(s)
|
||||||
|
|
||||||
NB
|
NB
|
||||||
* Periodically do a big stress-test and check for leaks, mysql overload etc..
|
* Periodically do a big stress-test and check for leaks, mysql overload etc..
|
||||||
|
|
|
||||||
1
app.psgi
1
app.psgi
|
|
@ -6,6 +6,7 @@ use WebGUI;
|
||||||
my $wg = WebGUI->new( root => '/data/WebGUI', site => 'dev.localhost.localdomain.conf' );
|
my $wg = WebGUI->new( root => '/data/WebGUI', site => 'dev.localhost.localdomain.conf' );
|
||||||
|
|
||||||
builder {
|
builder {
|
||||||
|
enable 'Debug', panels => [ qw(Environment Response Timer Memory Session DBITrace PerlConfig Response) ];
|
||||||
|
|
||||||
# Open/close the WebGUI::Session at the outer-most onion layer
|
# Open/close the WebGUI::Session at the outer-most onion layer
|
||||||
enable '+WebGUI::Middleware::Session', config => $wg->config;
|
enable '+WebGUI::Middleware::Session', config => $wg->config;
|
||||||
|
|
|
||||||
|
|
@ -101,15 +101,6 @@ sub compile_psgi_app {
|
||||||
# Handle the request
|
# Handle the request
|
||||||
$self->handle($session);
|
$self->handle($session);
|
||||||
|
|
||||||
# Uncomment to catch errors (currently I prefer letting StackTrace do its thing)
|
|
||||||
# try {
|
|
||||||
# $self->handle($session);
|
|
||||||
# } catch {
|
|
||||||
# $session->request->log( "Error handling request: $_" );
|
|
||||||
# $responder->( $catch );
|
|
||||||
# return;
|
|
||||||
# };
|
|
||||||
|
|
||||||
# Construct the PSGI response
|
# Construct the PSGI response
|
||||||
my $response = $session->response;
|
my $response = $session->response;
|
||||||
my $psgi_response = $response->finalize;
|
my $psgi_response = $response->finalize;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,6 @@ sub handler {
|
||||||
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
|
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
|
||||||
$http->setStatus("304","Content Not Modified");
|
$http->setStatus("304","Content Not Modified");
|
||||||
$http->sendHeader;
|
$http->sendHeader;
|
||||||
$session->close;
|
|
||||||
return "chunked";
|
return "chunked";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,7 +127,6 @@ sub handler {
|
||||||
my $ct = guess_media_type($filename);
|
my $ct = guess_media_type($filename);
|
||||||
my $oldContentType = $request->content_type($ct);
|
my $oldContentType = $request->content_type($ct);
|
||||||
if ($request->sendfile($filename) ) {
|
if ($request->sendfile($filename) ) {
|
||||||
$session->close;
|
|
||||||
return; # TODO - what should we return to indicate streaming?
|
return; # TODO - what should we return to indicate streaming?
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -463,9 +463,6 @@ sub open {
|
||||||
$self->{_request} = $request;
|
$self->{_request} = $request;
|
||||||
$self->{_response} = $request->new_response( 200 );
|
$self->{_response} = $request->new_response( 200 );
|
||||||
|
|
||||||
# TODO: it might be nice to set a default Content-Type here, but we can't until Assets can override it again
|
|
||||||
# $self->{_response} = $request->new_response( 200 );#, [ 'Content-Type' => 'text/html; charset=UTF-8' ] );
|
|
||||||
|
|
||||||
# Use the WebGUI::Session::Request object to look up the sessionId from cookies, if it
|
# Use the WebGUI::Session::Request object to look up the sessionId from cookies, if it
|
||||||
# wasn't given explicitly
|
# wasn't given explicitly
|
||||||
$sessionId ||= $request->cookies->{$config->getCookieName};
|
$sessionId ||= $request->cookies->{$config->getCookieName};
|
||||||
|
|
|
||||||
|
|
@ -223,11 +223,10 @@ sub fatal {
|
||||||
|
|
||||||
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
|
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
|
||||||
$self->session->http->setStatus("500","Server Error");
|
$self->session->http->setStatus("500","Server Error");
|
||||||
#Apache2::RequestUtil->request->content_type('text/html') if ($self->session->request);
|
$self->session->response->content_type('text/html') if ($self->session->response);
|
||||||
$self->session->request->content_type('text/html') if ($self->session->request);
|
|
||||||
$self->getLogger->fatal($message);
|
$self->getLogger->fatal($message);
|
||||||
$self->getLogger->debug("Stack trace for FATAL ".$message."\n".$self->getStackTrace());
|
$self->getLogger->debug("Stack trace for FATAL ".$message."\n".$self->getStackTrace());
|
||||||
$self->session->http->sendHeader if ($self->session->request);
|
$self->session->http->sendHeader if ($self->session->response);
|
||||||
|
|
||||||
if (! defined $self->session->db(1)) {
|
if (! defined $self->session->db(1)) {
|
||||||
# We can't even _determine_ whether we can show the debug text. Punt.
|
# We can't even _determine_ whether we can show the debug text. Punt.
|
||||||
|
|
|
||||||
|
|
@ -279,13 +279,13 @@ sub sendHeader {
|
||||||
$response->header(Location => $self->getRedirectLocation);
|
$response->header(Location => $self->getRedirectLocation);
|
||||||
$response->status($self->getStatus);
|
$response->status($self->getStatus);
|
||||||
} else {
|
} else {
|
||||||
$request->content_type($self->getMimeType);
|
$response->content_type($self->getMimeType);
|
||||||
my $cacheControl = $self->getCacheControl;
|
my $cacheControl = $self->getCacheControl;
|
||||||
my $date = ($userId eq "1") ? $datetime->epochToHttp($self->getLastModified) : $datetime->epochToHttp;
|
my $date = ($userId eq "1") ? $datetime->epochToHttp($self->getLastModified) : $datetime->epochToHttp;
|
||||||
# under these circumstances, don't allow caching
|
# under these circumstances, don't allow caching
|
||||||
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
|
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
|
||||||
$response->header("Cache-Control" => "private, max-age=1");
|
$response->header("Cache-Control" => "private, max-age=1");
|
||||||
# $request->no_cache(1); # TODO - re-enable this?
|
# $response->no_cache(1); # TODO - re-enable this?
|
||||||
}
|
}
|
||||||
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
|
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue