Alice
view release on metacpan or search on metacpan
lib/Alice/HTTP/Request.pm view on Meta::CPAN
171819202122232425262728293031323334}
sub
new_response {
my
$self
=
shift
;
Alice::HTTP::Response->new(
$self
->{cb},
@_
);
}
sub
param {
my
$self
=
shift
;
if
(
wantarray
) {
return
map
{decode(
"utf8"
,
$_
)}
$self
->SUPER::param(
@_
);
}
else
{
return
decode(
"utf8"
,
$self
->SUPER::param(
@_
));
}
}
1;
lib/Alice/HTTP/Response.pm view on Meta::CPAN
1112131415161718192021222324252627282930313233343536373839404142
my
$self
=
bless
{
cb
=>
$cb
},
$class
;
$self
->status(
$rc
)
if
defined
$rc
;
$self
->headers(
$headers
)
if
defined
$headers
;
$self
->body(
$content
)
if
defined
$content
;
$self
;
}
sub
send
{
my
$self
=
shift
;
my
$res
=
$self
->SUPER::finalize;
$res
->[2] = [
map
encode(
"utf8"
,
$_
), @{
$res
->[2]}];
return
$self
->{cb}->(
$res
);
}
sub
notfound {
my
$self
=
shift
;
return
$self
->{cb}->([404, [
"Content-Type"
,
"text/plain"
,
"Content-Length"
, 9], [
'not found'
]]);
}
sub
ok {
my
$self
=
shift
;
return
$self
->{cb}->([200, [
"Content-Type"
,
"text/plain"
,
"Content-Length"
, 2], [
'ok'
]]);
}
sub
writer {
my
$self
=
shift
;
my
$response
=
$self
->SUPER::finalize;
return
$self
->{cb}->([
@$response
[0,1]]);
}
1;
( run in 0.363 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )