Lemonldap::NG::Common::PSGI::Request(3pm) | User Contributed Perl Documentation | Lemonldap::NG::Common::PSGI::Request(3pm) |
Lemonldap::NG::Common::PSGI::Request - HTTP request object for Lemonldap::NG PSGIs
package My::PSGI; use base Lemonldap::NG::Common::PSGI; # See Lemonldap::NG::Common::PSGI ... sub handler { my ( $self, $req ) = @_; # Do something and return a PSGI response # NB: $req is a Lemonldap::NG::Common::PSGI::Request object if ( $req->accept eq 'text/plain' ) { ... } return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Body lines' ] ]; }
This package provides HTTP request objects used by Lemonldap::NG PSGIs. It contains common accessors to work with request. Note that it inherits from Plack::Request.
All methods of Plack::Request are available. Lemonldap::NG::Common::PSGI::Request adds the following methods:
'Accept' header content.
'Accept-Encoding' header content.
Used to store error value (usually a Lemonldap::NG::Portal::Main::Constants constant).
Get the content of a JSON POST request as Perl object.
'Accept-Language header content.
'Host' header content.
Since body() methods returns an IO::Handle object, this method reads and return the request content as string.
Accessor to 'respHeaders' property. It is used to store headers that have to be pushed in response (see Lemonldap::NG::Common::PSGI).
Be careful, it contains an array reference, not a hash one because headers can be multi-valued.
Example:
# Set headers $req->respHeaders( "Location" => "http://x.y.z/", Etag => "XYZ", ); # Add header $req->respHeaders->{"X-Key"} = "Value";
Returns headers array and flush it.
Plack::Request param() method is read-only. This method can be used to modify a GET parameter value
REQUEST_URI environment variable decoded.
REMOTE_USER environment variable. It contains username when a server authentication is done.
Hash reference to the session information (if app inherits from Lemonldap::NG::Handler::PSGI or any other handler PSGI package). If no session information is available, it contains:
{ _whatToTrace => <REMOTE-USER value> }
Return true if current request ask JSON content (verify that "Accept" header contains "application/json" or "text/json").
<http://lemonldap-ng.org/>, Lemonldap::NG::Common::PSGI, Lemonldap::NG::Hander::PSGI, Plack::Request, Lemonldap::NG::Portal::Main::Constants,
Use OW2 system to report bug or ask for features: <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
Lemonldap::NG is available at <http://forge.objectweb.org/project/showfiles.php?group_id=274>
See COPYING file for details.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
2023-09-29 | perl v5.32.1 |