Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Protocol is now an attrib rather than an environment variable.

  • Loading branch information...
commit 249191929328d66e96998515de18fae49bfa2755 1 parent fa96685
Timothy Totten authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/HTTP/Easy.pm
5 lib/HTTP/Easy.pm
View
@@ -10,6 +10,7 @@ role HTTP::Easy {
has $!connection is rw; ## To be populated by accept().
has %!env; ## The environment, generated by run().
has $!body is rw; ## Any request body, populated by run().
+ has $.protocol is rw; ## HTTP version statement. Set by run.
method run {
$*ERR.say: "{time} Started HTTP server.";
@@ -24,8 +25,8 @@ role HTTP::Easy {
my ($path, $query) = $uri.split('?', 2);
$query //= '';
## First, let's add our "known" headers.
+ $.protocol = $protocol;
%!env<REQUEST_METHOD> = $method;
- %!env<PROTOCOL> = $protocol;
%!env<QUERY_STRING> = $query;
%!env<PATH_INFO> = $path;
%!env<REQUEST_URI> = $uri;
@@ -48,7 +49,7 @@ role HTTP::Easy {
}
## Anything left in @request is now the body.
$!body = @request.join("\x0D\x0A"); ## Put it back together with CRLF.
- my $res = self.handler; ## Call our handler. It can return an HTTP response, or handle it itself.
+ my $res = self.handler; ## Call our handler. It can return an HTTP response, or handle it itself, in which case it should return Nil.
if defined $res {
$!connection.send($res);
}
Please sign in to comment.
Something went wrong with that request. Please try again.