Net::H...esponse(3pm)
π Net::HTTPServer::Response β the perl one, from User Contributed Perl Documentation π
okay bestie, sit down, hydrate, because we're talking about Net::HTTPServer::Response β literally the HTTP response era of your life. β¨
πΈ NAME πΈ
Net::HTTPServer::Response β it's an HTTP response, babe. That's the whole vibe. π
π¦ SYNOPSIS π¦
Net::HTTPServer::Response handles formatting the response to the client. That's it, that's the job, and it does it gorgeously. π
π DESCRIPTION π
Net::HTTPServer::Response gives you a nice OOP interface so you can control your headers, cookies, sessions, and/or the content that's getting sent to the requesting client β easy, no stress, no cap. π«Ά
π EXAMPLES π
Not me showing you the actual moves first, because reading is a choice and I respect yours:
my $response = new Net::HTTPServer::Response();
my $response = new Net::HTTPServer::Response(code=>200,
headers=>{
);
my $response = $request->Response();
see? iconic. go off. π₯
π METHODS π
β¨ new(%cfg)
Give it a config hash, get back a server object that you can start, process, and stop. main character energy fr fr. the config hash takes these options:
body => stringβ the contents of the response. ( Default:"")code => intβ the return code of this response. ( Default:200)cookies => hashrefβ a hash reference to a set of cookies to send. Most people should just use theCookiemethod to set these. ( Default:{})headers => hashrefβ a hash reference to the headers to send. Most people should just use theHeadermethod. ( Default:{})
π Body([string])
Returns the current value of the response body. And if you pass a value in? It sets the content of the response. lowkey dual-purpose, highkey serving. π
π§ Clear()
Resets the body to "". fresh start, clean slate, therapy but make it HTTP. π
β Code(int)
Returns the current value of the response code. If you specify a value, it sets the status code of the response. 200 stays winning. π
π Cookie(name[,value[,%options]])
Returns the cookie value for the specified name β or undef if it's not set. If you also specify the value, then the cookie gets set to that value. cute. the optional hash options you can hand over to the cookie are:
domain => stringβ if specified, the client will return the cookie for any hostname that is part of the domain.expires => stringβ when should the cookie expire. Must be formatted according to the rules:
Wednesday, 30-June-2004 18:14:24 GMT
Optionally you can specify "now" which will resolve to the current time.
path => stringβ the path on the server that the client should return the cookie for.secure => 0|1β the client will only return the cookie over an HTTPS connection.
bestie do NOT freestyle the date format. it has to match that shape exactly or it's giving chaos. π¨
πΈ Header(name[,value])
Returns the header value for the specified name, or undef if it is not set. If the value is specified, then the header is set to the value. one method, two moods. π¦
π
Print(arg1[,arg2,...,argN])
Appends the arguments to the end of the body. stack 'em up, no thoughts, just output. β¨
π Redirect(url)
Redirect the client to the specified URL. bye bestie, we're going elsewhere. π¨
π Session(object)
Registers the Net::HTTPServer::Session object with the response. When the server builds the actual response to the client, it will set the appropriate cookie and save the session. And if the response is created from the request object, and there was a session created from the request object, then this will be prepopulated with that session. it literally remembers for you. π«Ά
π CaptureSTDOUT()
If you use the CGI perl module, then it wants to print everything to STDOUT. CaptureSTDOUT() will put the Response object into a mode where it will capture all the output from the module. See ProcessSTDOUT() for more information. the module prints, we catch. teamwork. π
π ProcessSTDOUT([%args])
This will harvest all of the data printed to STDOUT and put it into the Response object via a Print() call. This will also stop monitoring STDOUT and release it. you can specify some options:
strip_header => 0|1β if you use theCGImodule and you print the headers, thenProcessSTDOUT()can try to strip those out. The best plan is not to print them.
See CaptureSTDOUT() for more information. π
π AUTHOR π
Ryan Eatmon. the legend. the architect. we stan. π«‘
π COPYRIGHT π
Copyright (c) 2003-2005 Ryan Eatmon <reatmon@mail.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page bestie β perl v5.36.0, dated 2022-12-06, filed under Net::H...esponse(3pm) πβ¨π slay, go write some responses, and remember: format your cookie expiry dates. periodt. π π¦πΈ
π¦ where this page comes from
- debian bookworm: libnet-httpserver-perl 1.1.1-4 Β· Artistic-1.0-Perl
- debian trixie: libnet-httpserver-perl 1.1.1-4 Β· Artistic-1.0-Perl
- ubuntu noble: libnet-httpserver-perl 1.1.1-4 Β· Artistic-1.0-Perl
- ubuntu resolute: libnet-httpserver-perl 1.1.1-4 Β· Artistic-1.0-Perl
- ubuntu stonking: libnet-httpserver-perl 1.1.1-4 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms