let you not finalize a request when you wish to jailbreak psgi
John Napiorkowski [Tue, 21 May 2013 17:52:52 +0000 (13:52 -0400)]
Changes
lib/Catalyst.pm
lib/Catalyst/Request.pm
lib/Catalyst/Response.pm
t/author/spelling.t

diff --git a/Changes b/Changes
index ae86e24..e02ae76 100644 (file)
--- a/Changes
+++ b/Changes
@@ -8,7 +8,8 @@ TBA
     as it's been removed from core. RT#84787
   - New support for closing over the PSGI $writer object, useful for working
     with event loops.
-
+  - lets you access a psgix.io socket, if your server supports it, for manual
+    handling of the client - server communication, such as for websockets.
 
 5.90030 - 2013-04-12
   ! POSSIBLE BREAKING CHANGE: Removed Regexp dispatch type from core, and put
index 068c102..bc92f5f 100644 (file)
@@ -1793,6 +1793,11 @@ sub finalize {
         $c->log->error($error);
     }
 
+    # Support skipping finalize for psgix.io style 'jailbreak'.  Used to support
+    # stuff like cometd and websockets
+    
+    return if $c->request->has_io_fh;
+
     # Allow engine to handle finalize flow (for POE)
     my $engine = $c->engine;
     if ( my $code = $engine->can('finalize') ) {
index dce7a05..17f0be9 100644 (file)
@@ -91,6 +91,19 @@ has _log => (
     required => 1,
 );
 
+has io_fh => (
+  is=>'ro',
+  predicate=>'has_io_fh',
+  lazy=>1,
+  builder=>'_build_io_fh');
+
+  sub _build_io_fh {
+    my $self = shift;
+    return $self->env->{'psgix.io'}
+      || die "Your Server does not support psgix.io";
+  };
+
+
 # Amount of data to read from input on each pass
 our $CHUNKSIZE = 64 * 1024;
 
@@ -846,6 +859,12 @@ Returns the value of the C<REMOTE_USER> environment variable.
 Shortcut to $req->headers->user_agent. Returns the user agent (browser)
 version string.
 
+=head2 $req->io_fh
+
+Returns a psgix.io bidirectional socket, if your server supports one.  Used for
+when you want to jailbreak out of PSGI and handle bidirectional client server
+communication manually, such as when you are using cometd or websockets.
+
 =head1 SETUP METHODS
 
 You should never need to call these yourself in application code,
index 8559f36..3af1eef 100644 (file)
@@ -29,7 +29,8 @@ has _writer => (
 has write_fh => (
   is=>'ro',
   predicate=>'has_write_fh',
-  lazy_build=>1);
+  lazy=>1,
+  builder=>'_build_write_fh');
 
   sub _build_write_fh {
     my $self = shift;
index 4213b3b..465c5eb 100644 (file)
@@ -18,7 +18,7 @@ add_stopwords(qw(
     wiki bitmask uri url urls dir hostname proxied http https IP SSL
     inline INLINE plugins cpanfile
     FastCGI Stringifies Rethrows DispatchType Wishlist Refactor ROADMAP HTTPS Unescapes Restarter Nginx Refactored
-    ActionClass LocalRegex LocalRegexp MyAction metadata
+    ActionClass LocalRegex LocalRegexp MyAction metadata cometd io psgix websockets
     Andreas
     Ashton
     Axel