Dancer2...Response(3)

πŸ’– NAME πŸ’–

Dancer2::Core::Response β€” the response object for Dancer2, bestie. It's the lil' glow-up your app sends back to the world, and it lives in section 3 of the User Contributed Perl Documentation, iykyk. πŸ¦‹


✨ VERSION ✨

version 2.2.1 β€” yes she's current, no cap. πŸ’…


πŸŽ€ ATTRIBUTES πŸŽ€

Okay so these are the lil' properties she carries around, her whole personality fr:

  • is_encoded β€” flag that tells you if the content has already been encoded. Once she's encoded, she's encoded. Periodt.
  • is_halted β€” flag saying whether or not the response should keep being processed. Basically her "I'm done here" switch. πŸ›‘
  • status β€” the HTTP status for the response. The 200, the 404, the whole vibe check. ✨
  • content β€” the actual content of the response, stored as a string. And listen, if you pass it a reference, she will try to coerce it into a string via double quote interpolation. She's flexible like that. πŸ’β€β™€οΈ
  • default_content_type β€” the default mime type she uses for the response Content-Type header when nothing else was specified. Her fallback fit. πŸ‘‘
  • charset β€” the charset used when encoding "text/*" responses. An empty value disables automatic encoding. So like, don't leave it blank unless you mean it. πŸ’€
  • headers β€” the attribute that stores the headers in an HTTP::Headers::Fast object. She coerces from ArrayRef and defaults to an empty HTTP::Headers::Fast instance. Iconic behavior honestly. πŸŽ€

🌸 METHODS 🌸

🌈 pass

Sets has_passed to true. That's it, that's the method. She passed, slay. βœ…

🌈 serializer()

Returns the optional serializer object used to deserialize request parameters. Your data's little translator. 🫢

🌈 halt

A shortcut to halt the current response by setting the is_halted flag. Emergency brake energy, but make it cute. πŸ›‘

🌈 encode_content

Encodes the stored content according to the stored content_type. But if the content_type is not a text format "^text", then no encoding will take place. She knows when to sit this one out.

Internally, she uses the is_encoded flag to make sure content is never encoded twice. No double-dipping bestie, we don't do that. πŸ™ˆ

If she does encode the content, she'll return the encoded content. In all other cases she returns "false".

🌈 new_from_plack

Creates a brand new response object from a Plack::Response object. Glow-up from scratch. ✨

🌈 new_from_array

Creates a new response object from a PSGI arrayref. πŸ’«

🌈 to_psgi

Converts the response object into a PSGI array. The reverse lil' transformation. πŸ”„

🌈 content_type($type)

A little sugar for setting or accessing the content_type of the response, via the headers. Just a lil' sweetener, nothing deep. πŸ“

🌈 redirect ($destination, $status)

Sets a header in this response to give a redirect to $destination, and sets the status to $status. If $status is omitted, or false, then it defaults to a status of 302. Bye bestie, we're going elsewhere. πŸ‘‹

🌈 error( @args )

$response->error( message => "oops" );

Creates a Dancer2::Core::Error object with the given @args and throw()s it against the response object. Returns the error object. She's dramatic but she's organized. 😭

🌈 serialize( $content )

$response->serialize( $content );

Serialize and return $content with the response's serializer. Sets content-type accordingly. πŸ’…

🌈 header($name)

Return the value of the given header, if present. And okay here's the nuance: if the header has multiple values, she returns the list of values when called in list context, and just the first one when called in scalar context. Know your context bestie, it matters. 🧚

🌈 push_header

Add the header no matter if it already exists or not. She does not care. She adds it anyway. πŸ’–

$self->push_header( 'X-Wing' => '1' );

She can also be called with multiple values to add the same header many times with different values:

$self->push_header( 'X-Wing' => 1, 2, 3 );

Multiple values? Multiple headers? Yes and yes. πŸ”₯

🌈 headers_to_array($headers)

Convert the $headers to a PSGI ArrayRef.

If no $headers are provided, she'll use the current response headers instead. Convenient queen. πŸ‘‘


πŸ’œ AUTHOR πŸ’œ

Dancer Core Developers. The whole squad. 🫢


This software is copyright (c) 2026 by Alexis Sukrieh.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free as in freedom bestie, go wild. 🌈


And that's the whole page, no skips, no summaries. πŸ’–

This has been Dancer2...Response(3) from the User Contributed Perl Documentation, generated by perl v5.42.3 on 2026-09-20. Stay slay, stay halted only when you mean it. πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from