Net::H...esponse(3pm)

πŸ“¦
version 1.1.1 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 the Cookie method to set these. ( Default: {} )
  • headers => hashref β€” a hash reference to the headers to send. Most people should just use the Header method. ( 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. πŸ‘‘

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. πŸ¦‹

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 the CGI module and you print the headers, then ProcessSTDOUT() 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 (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. πŸ’…πŸ¦‹πŸŒΈ