Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated examples for content-length and array flattening changes.

  • Loading branch information...
commit 6e6acebfcc582abfae45ffa2bf276886d203856c 1 parent 0d449a8
Timothy Totten authored
Showing with 17 additions and 5 deletions.
  1. +10 −2 README.md
  2. +4 −1 test/alternative.p6
  3. +3 −2 test/recommended.p6
View
12 README.md
@@ -32,7 +32,8 @@ with PSGI-compliant output. Here's an example:
my $status = '200';
my @headers = 'Content-Type' => 'text/plain';
my @body = "Hello $name\n";
- return [ $status, @headers, @body ];
+ @headers.push: 'Content-Length' => @body.join.encode.bytes;
+ return [ $status, \@headers, \@body ];
}
$scgi.handle: $handler;
@@ -51,7 +52,10 @@ or using a raw HTTP output instead of PSGI. Here's an example doing both:
if $request.success
{
my $name = $request.env<QUERY_STRING> || 'world';
- $connection.send("Content-type: text/plain\n\nHello $name\n");
+ my $return = "Hello $name\n";
+ my $len = $return.encode.bytes;
+ my $headers = "Content-Type: text/plain\nContent-Length: $len\n";
+ $connection.send("$headers\n$return");
}
$connection.close;
}
@@ -59,6 +63,10 @@ or using a raw HTTP output instead of PSGI. Here's an example doing both:
Test script representing both examples can be found in the 'test' folder.
+If you are serious about using SCGI for web application development, see
+[WWW::App](https://github.com/supernovus/perl6-www-app/) which makes building
+web apps MUCH easier!
+
## Configuration
### lighttpd
View
5 test/alternative.p6
@@ -16,7 +16,10 @@ while (my $connection = $scgi.accept())
if $request.success
{
my $name = $request.env<QUERY_STRING> || 'World';
- $connection.send("Content-type: text/plain\n\nHello $name\n");
+ my $return = "Hello $name\n";
+ my $len = $return.encode.bytes;
+ my $headers = "Content-Type: text/plain\nContent-Length: $len\n";
+ $connection.send("$headers\n$return");
}
$connection.close;
}
View
5 test/recommended.p6
@@ -14,8 +14,9 @@ my $handler = sub (%env)
my $name = %env<QUERY_STRING> || 'World';
my $status = '200';
my @headers = 'Content-Type' => 'text/plain';
- my @body = "Hello $name\n";;
- return [ $status, @headers, @body ];
+ my @body = "Hello $name\n";
+ @headers.push: 'Content-Length' => @body.join.encode.bytes;
+ return [ $status, \@headers, \@body ];
}
$scgi.handle: $handler;
Please sign in to comment.
Something went wrong with that request. Please try again.