Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Using PSGI library now.
  • Loading branch information
Timothy Totten committed Apr 29, 2013
1 parent 8eabf94 commit c0bc1eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 43 deletions.
2 changes: 1 addition & 1 deletion META.info
Expand Up @@ -2,6 +2,6 @@
"name" : "HTTP::Easy",
"version" : "*",
"description" : "HTTP servers made easy, including PSGI",
"depends" : [ "HTTP::Status" ],
"depends" : [ "HTTP::Status", "PSGI" ],
"source-url" : "git://github.com/supernovus/perl6-http-easy.git"
}
2 changes: 1 addition & 1 deletion lib/HTTP/Easy.pm6
Expand Up @@ -147,7 +147,7 @@ method run
## If it returns an undefined value, we assume the handler
## sent the response to the client directly, and end the session.
my $res = self.handler;
if defined $res
if $res.defined
{
if $res ~~ Buf
{
Expand Down
44 changes: 3 additions & 41 deletions lib/HTTP/Easy/PSGI.pm6
Expand Up @@ -6,9 +6,7 @@ use HTTP::Easy;
class HTTP::Easy::PSGI:ver<2.1.3>:auth<http://supernovus.github.com/>
does HTTP::Easy;

use HTTP::Status;

constant $CRLF = "\x0D\x0A";
use PSGI;

has $!app;

Expand Down Expand Up @@ -42,44 +40,8 @@ method handler
{
die "Invalid {self.WHAT} application.";
}
my $message = get_http_status_msg($result[0]);
my $output = $.http-protocol ~ ' ' ~ $result[0] ~ " $message$CRLF";
for @($result[1]) -> $header
{
$output ~= $header.key ~ ': ' ~ $header.value ~ $CRLF;
}
my @body = $result[2];
my $body;
for @body -> $segment
{
if ! $body.defined
{
$body = $segment;
}
elsif $body ~~ Buf
{
if $segment ~~ Buf
{
$body ~= $segment;
}
else
{
$body ~= $segment.Str.encode;
}
}
else
{
$body ~= $segment;
}
}
if $body ~~ Buf
{
$output = ($output~$CRLF).encode ~ $body;
}
else
{
$output ~= $CRLF ~ $body;
}
my $protocol = $.http-protocol;
my $output = encode-psgi-response($result, :$protocol, :nph);
return $output;
}

Expand Down

0 comments on commit c0bc1eb

Please sign in to comment.