| 1 | package Eve::HttpResponse; | ||
| 2 | |||
| 3 | 11 | ▶ | use parent qw(Eve::Class); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 11 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 11 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | B<Eve::HttpResponse> - an HTTP response abstract class. | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | use Eve::HttpResponse::Implementation; | ||
| 15 | |||
| 16 | $response->set_status(code => 302); | ||
| 17 | $response->set_header(name => 'Location', value => '/other'); | ||
| 18 | $response->set_cookie( | ||
| 19 | name => 'cookie1', | ||
| 20 | value => 'value', | ||
| 21 | domain => '.example.com', | ||
| 22 | path => '/some/', | ||
| 23 | expires => '+1d', | ||
| 24 | secure = >1); | ||
| 25 | $response->set_body(text => 'Hello world!'); | ||
| 26 | |||
| 27 | print $response->get_text(); | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | The class is an interface defining abstraction that is required to be | ||
| 32 | used as a parent class for various HTTP response implementations. | ||
| 33 | |||
| 34 | =head1 METHODS | ||
| 35 | |||
| 36 | =head2 B<init()> | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | 12 | ▶ | sub init { |
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||
| 41 | 12 | my $self = shift; | |
| 42 | |||
| 43 | 12 | $self->{'_header_hash'} = {}; | |
| 44 | 12 | $self->{'_cookie_list'} = []; | |
| 45 | 12 | $self->{'_code'} = 200; | |
| 46 | 12 | $self->{'_body'} = ''; | |
| 47 | |||
| 48 | 12 | return; | |
| 49 | } | ||
| 50 | |||
| 51 | =head2 B<set_header()> | ||
| 52 | |||
| 53 | Sets or overwrites an HTTP header of the response. | ||
| 54 | |||
| 55 | =head3 Arguments | ||
| 56 | |||
| 57 | =over 4 | ||
| 58 | |||
| 59 | =item C<name> | ||
| 60 | |||
| 61 | =item C<value> | ||
| 62 | |||
| 63 | =back | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | 1 | ▶ | sub set_header { |
|
Subroutine
set_header: called CC=1 SCAR=0.0
Pod
documented
| |||
| 68 | 1 | Eve::Error::NotImplemented->throw(); | |
| 69 | } | ||
| 70 | |||
| 71 | =head2 B<set_status()> | ||
| 72 | |||
| 73 | Sets or overwrites the HTTP response status. | ||
| 74 | |||
| 75 | =head3 Arguments | ||
| 76 | |||
| 77 | =over 4 | ||
| 78 | |||
| 79 | =item C<code> | ||
| 80 | |||
| 81 | =back | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | 1 | ▶ | sub set_status { |
|
Subroutine
set_status: called CC=1 SCAR=0.0
Pod
documented
| |||
| 86 | 1 | Eve::Error::NotImplemented->throw(); | |
| 87 | } | ||
| 88 | |||
| 89 | =head2 B<set_cookie()> | ||
| 90 | |||
| 91 | Sets an HTTP response cookie. | ||
| 92 | |||
| 93 | =head3 Arguments | ||
| 94 | |||
| 95 | =over 4 | ||
| 96 | |||
| 97 | =item C<name> | ||
| 98 | |||
| 99 | =item C<value> | ||
| 100 | |||
| 101 | =item C<domain> | ||
| 102 | |||
| 103 | =item C<path> | ||
| 104 | |||
| 105 | =item C<expires> | ||
| 106 | |||
| 107 | =item C<secure> | ||
| 108 | |||
| 109 | (optional) defaults to false | ||
| 110 | |||
| 111 | =back | ||
| 112 | |||
| 113 | =cut | ||
| 114 | |||
| 115 | 1 | ▶ | sub set_cookie { |
|
Subroutine
set_cookie: called CC=1 SCAR=0.0
Pod
documented
| |||
| 116 | 1 | Eve::Error::NotImplemented->throw(); | |
| 117 | } | ||
| 118 | |||
| 119 | =head2 B<set_body()> | ||
| 120 | |||
| 121 | Sets or overwrites the HTTP response body. | ||
| 122 | |||
| 123 | =head3 Arguments | ||
| 124 | |||
| 125 | =over 4 | ||
| 126 | |||
| 127 | =item C<text> | ||
| 128 | |||
| 129 | =back | ||
| 130 | |||
| 131 | =cut | ||
| 132 | |||
| 133 | 1 | ▶ | sub set_body { |
|
Subroutine
set_body: called CC=1 SCAR=0.0
Pod
documented
| |||
| 134 | 1 | Eve::Error::NotImplemented->throw(); | |
| 135 | } | ||
| 136 | |||
| 137 | =head2 B<get_text()> | ||
| 138 | |||
| 139 | =head3 Returns | ||
| 140 | |||
| 141 | The HTTP response as text. | ||
| 142 | |||
| 143 | =cut | ||
| 144 | |||
| 145 | 1 | ▶ | sub get_text { |
|
Subroutine
get_text: called CC=1 SCAR=0.0
Pod
documented
| |||
| 146 | 1 | Eve::Error::NotImplemented->throw(); | |
| 147 | } | ||
| 148 | |||
| 149 | =head1 SEE ALSO | ||
| 150 | |||
| 151 | =over 4 | ||
| 152 | |||
| 153 | =item C<Eve::Class> | ||
| 154 | |||
| 155 | =back | ||
| 156 | |||
| 157 | =head1 LICENSE AND COPYRIGHT | ||
| 158 | |||
| 159 | Copyright 2012 Igor Zinovyev. | ||
| 160 | |||
| 161 | This program is free software; you can redistribute it and/or modify it | ||
| 162 | under the terms of either: the GNU General Public License as published | ||
| 163 | by the Free Software Foundation; or the Artistic License. | ||
| 164 | |||
| 165 | See http://dev.perl.org/licenses/ for more information. | ||
| 166 | |||
| 167 | |||
| 168 | =head1 AUTHORS | ||
| 169 | |||
| 170 | =over 4 | ||
| 171 | |||
| 172 | =item L<Igor Zinovyev|mailto:zinigor@gmail.com> | ||
| 173 | |||
| 174 | =back | ||
| 175 | |||
| 176 | =cut | ||
| 177 | |||
| 178 | 11 | 1; | |