Turned on Debug middleware

Removed unnecessary $session->close() now that we have WebGUI::Middleware::Session
Fixed Content-Type bug
This commit is contained in:
Patrick Donelan 2010-04-09 18:06:43 -04:00
parent 10e8d1898d
commit f22020c267
7 changed files with 6 additions and 19 deletions

1
TODO
View file

@ -8,6 +8,7 @@ DONE
* WebGUI::authen API changed
* urlHandler API changed - no longer gets server, config
* Streaming response body
* Delete lib/WebGUI/URL and replace with new Middleware(s)
NB
* Periodically do a big stress-test and check for leaks, mysql overload etc..

View file

@ -6,6 +6,7 @@ use WebGUI;
my $wg = WebGUI->new( root => '/data/WebGUI', site => 'dev.localhost.localdomain.conf' );
builder {
enable 'Debug', panels => [ qw(Environment Response Timer Memory Session DBITrace PerlConfig Response) ];
# Open/close the WebGUI::Session at the outer-most onion layer
enable '+WebGUI::Middleware::Session', config => $wg->config;

View file

@ -101,15 +101,6 @@ sub compile_psgi_app {
# Handle the request
$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
my $response = $session->response;
my $psgi_response = $response->finalize;

View file

@ -113,7 +113,6 @@ sub handler {
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
$http->setStatus("304","Content Not Modified");
$http->sendHeader;
$session->close;
return "chunked";
}
@ -128,7 +127,6 @@ sub handler {
my $ct = guess_media_type($filename);
my $oldContentType = $request->content_type($ct);
if ($request->sendfile($filename) ) {
$session->close;
return; # TODO - what should we return to indicate streaming?
}
else {

View file

@ -463,9 +463,6 @@ sub open {
$self->{_request} = $request;
$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
# wasn't given explicitly
$sessionId ||= $request->cookies->{$config->getCookieName};

View file

@ -223,11 +223,10 @@ sub fatal {
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
$self->session->http->setStatus("500","Server Error");
#Apache2::RequestUtil->request->content_type('text/html') if ($self->session->request);
$self->session->request->content_type('text/html') if ($self->session->request);
$self->session->response->content_type('text/html') if ($self->session->response);
$self->getLogger->fatal($message);
$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)) {
# We can't even _determine_ whether we can show the debug text. Punt.

View file

@ -279,13 +279,13 @@ sub sendHeader {
$response->header(Location => $self->getRedirectLocation);
$response->status($self->getStatus);
} else {
$request->content_type($self->getMimeType);
$response->content_type($self->getMimeType);
my $cacheControl = $self->getCacheControl;
my $date = ($userId eq "1") ? $datetime->epochToHttp($self->getLastModified) : $datetime->epochToHttp;
# under these circumstances, don't allow caching
if ($userId ne "1" || $cacheControl eq "none" || $self->session->setting->get("preventProxyCache")) {
$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
else {