1Dancer2::Core::ResponseU(s3e)r Contributed Perl DocumentaDtainocner2::Core::Response(3)
2
3
4
6 Dancer2::Core::Response - Response object for Dancer2
7
9 version 0.300005
10
12 is_encoded
13 Flag to tell if the content has already been encoded.
14
15 is_halted
16 Flag to tell whether or not the response should continue to be
17 processed.
18
19 status
20 The HTTP status for the response.
21
22 content
23 The content for the response, stored as a string. If a reference is
24 passed, the response will try coerce it to a string via double quote
25 interpolation.
26
27 default_content_type
28 Default mime type to use for the response Content-Type header if
29 nothing was specified
30
31 headers
32 The attribute that store the headers in a HTTP::Headers::Fast object.
33
34 That attribute coerces from ArrayRef and defaults to an empty
35 HTTP::Headers::Fast instance.
36
38 pass
39 Set has_passed to true.
40
41 serializer()
42 Returns the optional serializer object used to deserialize request
43 parameters
44
45 halt
46 Shortcut to halt the current response by setting the is_halted flag.
47
48 encode_content
49 Encodes the stored content according to the stored content_type. If
50 the content_type is a text format "^text", then no encoding will take
51 place.
52
53 Internally, it uses the is_encoded flag to make sure that content is
54 not encoded twice.
55
56 If it encodes the content, then it will return the encoded content. In
57 all other cases it returns "false".
58
59 new_from_plack
60 Creates a new response object from a Plack::Response object.
61
62 new_from_array
63 Creates a new response object from a PSGI arrayref.
64
65 to_psgi
66 Converts the response object to a PSGI array.
67
68 content_type($type)
69 A little sugar for setting or accessing the content_type of the
70 response, via the headers.
71
72 redirect ($destination, $status)
73 Sets a header in this response to give a redirect to $destination, and
74 sets the status to $status. If $status is omitted, or false, then it
75 defaults to a status of 302.
76
77 error( @args )
78 $response->error( message => "oops" );
79
80 Creates a Dancer2::Core::Error object with the given @args and throw()
81 it against the response object. Returns the error object.
82
83 serialize( $content )
84 $response->serialize( $content );
85
86 Serialize and return $content with the response's serializer. set
87 content-type accordingly.
88
89 header($name)
90 Return the value of the given header, if present. If the header has
91 multiple values, returns the list of values if called in list context,
92 the first one if in scalar context.
93
94 push_header
95 Add the header no matter if it already exists or not.
96
97 $self->push_header( 'X-Wing' => '1' );
98
99 It can also be called with multiple values to add many times the same
100 header with different values:
101
102 $self->push_header( 'X-Wing' => 1, 2, 3 );
103
104 headers_to_array($headers)
105 Convert the $headers to a PSGI ArrayRef.
106
107 If no $headers are provided, it will use the current response headers.
108
110 Dancer Core Developers
111
113 This software is copyright (c) 2021 by Alexis Sukrieh.
114
115 This is free software; you can redistribute it and/or modify it under
116 the same terms as the Perl 5 programming language system itself.
117
118
119
120perl v5.32.1 2021-01-31 Dancer2::Core::Response(3)