Alice

 view release on metacpan or  search on metacpan

lib/Alice/HTTP/Request.pm  view on Meta::CPAN

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
}
 
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

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  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 )