diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-09-29 02:54:46 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-09-29 02:54:46 -0500 |
commit | 7e37206aca56e35defa7737c7e6179792c801ca0 (patch) | |
tree | f840bd2859f74d09717802c65fb3187c6062dffe | |
parent | d6d651e0bf9703dfc085673c947bdff8432a1003 (diff) | |
download | web-request-7e37206aca56e35defa7737c7e6179792c801ca0.tar.gz web-request-7e37206aca56e35defa7737c7e6179792c801ca0.zip |
stop slacking on the docs
-rw-r--r-- | lib/Web/Response.pm | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/Web/Response.pm b/lib/Web/Response.pm index 0526815..ae22bc0 100644 --- a/lib/Web/Response.pm +++ b/lib/Web/Response.pm @@ -274,6 +274,11 @@ overloads C<"">, an arrayref containing a list of either of those, a filehandle, or an object that implements the C<getline> and C<close> methods. Defaults to C<[]>. +=item streaming_response + +Instead of C<status>/C<headers>/C<content>, you can provide a coderef which +implements the streaming response API described in the L<PSGI> specification. + =item cookies A hashref of cookies to return with the response. The values in the hashref can @@ -285,6 +290,15 @@ from C<time>). Defaults to C<{}>. =back +In addition, a single parameter which is a valid PSGI response (a three element +arrayref or a coderef) will also be accepted, and will populate the attributes +as appropriate. If an arrayref is passed, the first element will be stored as +the C<status> attribute, the second element if it exists will be interpreted as +in the PSGI specification to create an L<HTTP::Headers> object and stored in +the C<headers> attribute, and the third element if it exists will be stored as +the C<content> attribute. If a coderef is passed, it will be stored in the +C<streaming_response> attribute. + =cut =method status($status) @@ -319,10 +333,22 @@ Shortcut for C<< $ret->headers->header('Location', $location) >>. Sets (and returns) the C<content> attribute, as described above. +=method streaming_response + +Sets and returns the streaming response coderef, as described above. + +=method has_streaming_response + +Returns whether or not a streaming response was provided. + =method cookies($cookies) Sets (and returns) the C<cookies> attribute, as described above. +=method has_cookies + +Returns whether or not any cookies have been defined. + =method redirect($location, $status) Sets the C<Location> header to $location, and sets the status code to $status @@ -330,7 +356,9 @@ Sets the C<Location> header to $location, and sets the status code to $status =method finalize -Returns a valid L<PSGI> response, based on the values given. +Returns a valid L<PSGI> response, based on the values given. This can be either +an arrayref or a coderef, depending on if an immediate or streaming response +was provided. If both were provided, the streaming response will be preferred. =cut |