.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 2024-03-07 "perl v5.38.2" "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 HTTP 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 PSGI 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 HTTP header section is sent with "Transfer-Encoding: chunked" (or "Connection: close" for HTTP/1.0 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 HTTP 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 HTTP/1.0 or HTTP/1.1, respectively. .Sp Normally, if the request was made with 1.1 then Feersum uses HTTP/1.1 for the response, otherwise HTTP/1.0 is used (this includes requests made with the HTTP "0.9" non-declaration). .Sp For streaming under HTTP/1.1 \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 "guard" in this context is some object that will do something interesting in its DESTROY/DEMOLISH 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.