.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Feersum::Connection 3pm" .TH Feersum::Connection 3pm "2020-12-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Feersum::Connection \- HTTP connection encapsulation .SH "SYNOPSIS" .IX Header "SYNOPSIS" For a streaming response: .PP .Vb 9 \& Feersum\->endjinn\->request_handler(sub { \& my $req = shift; # this is a Feersum::Connection object \& my $env = $req\->env(); \& my $w = $req\->start_streaming(200, [\*(AqContent\-Type\*(Aq => \*(Aqtext/plain\*(Aq]); \& # then immediately or after some time: \& $w\->write("Ergrates "); \& $w\->write(\e"FTW."); \& $w\->close(); \& }); .Ve .PP For a response with a Content-Length header: .PP .Vb 6 \& Feersum\->endjinn\->request_handler(sub { \& my $req = shift; # this is a Feersum::Connection object \& my $env = $req\->env(); \& $req\->start_whole_response(200, [\*(AqContent\-Type\*(Aq => \*(Aqtext/plain\*(Aq]); \& $req\->write_whole_body(\e"Ergrates FTW."); \& }); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Encapsulates an \s-1HTTP\s0 connection to Feersum. It's roughly analogous to an \&\f(CW\*(C`Apache::Request\*(C'\fR or \f(CW\*(C`Apache2::Connection\*(C'\fR object, but differs significantly in functionality. .PP Until Keep-Alive functionality is supported (if ever) this means that a connection is \fBalso\fR a request. .PP See Feersum for more examples on usage. .SH "METHODS" .IX Header "METHODS" .ie n .IP """my $env = $req\->env()""" 4 .el .IP "\f(CWmy $env = $req\->env()\fR" 4 .IX Item "my $env = $req->env()" Obtain an environment hash. This hash contains the same entries as for a \s-1PSGI\s0 handler environment hash. See Feersum for details on the contents. .Sp This is a method instead of a parameter so that future versions of Feersum can request a slice of the hash for speed. .ie n .IP """my $w = $req\->start_streaming($code, \e@headers)""" 4 .el .IP "\f(CWmy $w = $req\->start_streaming($code, \e@headers)\fR" 4 .IX Item "my $w = $req->start_streaming($code, @headers)" A full \s-1HTTP\s0 header section is sent with \*(L"Transfer-Encoding: chunked\*(R" (or \&\*(L"Connection: close\*(R" for \s-1HTTP/1.0\s0 clients). .Sp Returns a \f(CW\*(C`Feersum::Connection::Writer\*(C'\fR handle which should be used to complete the response. See Feersum::Connection::Handle for methods. .ie n .IP """$req\->send_response($code, \e@headers, $body)""" 4 .el .IP "\f(CW$req\->send_response($code, \e@headers, $body)\fR" 4 .IX Item "$req->send_response($code, @headers, $body)" .PD 0 .ie n .IP """$req\->send_response($code, \e@headers, \e@body)""" 4 .el .IP "\f(CW$req\->send_response($code, \e@headers, \e@body)\fR" 4 .IX Item "$req->send_response($code, @headers, @body)" .PD Respond with a full \s-1HTTP\s0 header (including \f(CW\*(C`Content\-Length\*(C'\fR) and body. .Sp Returns the number of bytes calculated for the body. .ie n .IP """$req\->force_http10""" 4 .el .IP "\f(CW$req\->force_http10\fR" 4 .IX Item "$req->force_http10" .PD 0 .ie n .IP """$req\->force_http11""" 4 .el .IP "\f(CW$req\->force_http11\fR" 4 .IX Item "$req->force_http11" .PD Force the response to use \s-1HTTP/1.0\s0 or \s-1HTTP/1.1,\s0 respectively. .Sp Normally, if the request was made with 1.1 then Feersum uses \s-1HTTP/1.1\s0 for the response, otherwise \s-1HTTP/1.0\s0 is used (this includes requests made with the \&\s-1HTTP \*(L"0.9\*(R"\s0 non-declaration). .Sp For streaming under \s-1HTTP/1.1\s0 \f(CW\*(C`Transfer\-Encoding: chunked\*(C'\fR is used, otherwise a \f(CW\*(C`Connection: close\*(C'\fR stream-style is used (with the usual non-guarantees about delivery). You may know about certain user-agents that support/don't\-support T\-E:chunked, so this is how you can override that. .Sp Supposedly clients and a lot of proxies support the \f(CW\*(C`Connection: close\*(C'\fR stream-style, see support in Varnish at http://www.varnish\-cache.org/trac/ticket/400 .ie n .IP """$req\->fileno""" 4 .el .IP "\f(CW$req\->fileno\fR" 4 .IX Item "$req->fileno" The socket file-descriptor number for this connection. .ie n .IP """$req\->response_guard($guard)""" 4 .el .IP "\f(CW$req\->response_guard($guard)\fR" 4 .IX Item "$req->response_guard($guard)" Register a guard to be triggered when the response is completely sent and the socket is closed. A \*(L"guard\*(R" in this context is some object that will do something interesting in its \s-1DESTROY/DEMOLISH\s0 method. For example, Guard. .SH "AUTHOR" .IX Header "AUTHOR" Jeremy Stashewsky, \f(CW\*(C`stash@cpan.org\*(C'\fR .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2010 by Jeremy Stashewsky & Socialtext Inc. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.