diff --git a/TODO b/TODO index de30c8e4d..b4ccc4950 100644 --- a/TODO +++ b/TODO @@ -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.. diff --git a/app.psgi b/app.psgi index e36b92f3b..4fbe77830 100644 --- a/app.psgi +++ b/app.psgi @@ -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; diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 445643c70..178fb61d2 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -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; diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index 6ea455947..bbbae724d 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -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 { diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index e27423320..030e88f72 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -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}; diff --git a/lib/WebGUI/Session/ErrorHandler.pm b/lib/WebGUI/Session/ErrorHandler.pm index 917fb6ebe..fcddcd73d 100644 --- a/lib/WebGUI/Session/ErrorHandler.pm +++ b/lib/WebGUI/Session/ErrorHandler.pm @@ -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. diff --git a/lib/WebGUI/Session/Http.pm b/lib/WebGUI/Session/Http.pm index 313486fc8..67e753e04 100644 --- a/lib/WebGUI/Session/Http.pm +++ b/lib/WebGUI/Session/Http.pm @@ -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 {