Created
August 13, 2013 14:25
-
-
Save towhans/6221613 to your computer and use it in GitHub Desktop.
Prototype of mapping from ZeroGW to PSGI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub zerogw2psgi { | |
my ($parts) = @_; | |
my $env; | |
# order of elements must be the same as in zerogw.yaml config file | |
# under key "contents" | |
$env->{REQUEST_METHOD} = $parts->[0]; | |
$env->{HTTP_AUTHORIZATION} = $parts->[1]; | |
$env->{HTTP_HOST} = $parts->[2]; | |
$env->{HTTP_ACCEPT_LANGUAGE} = $parts->[3]; | |
$env->{HTTP_ACCEPT} = $parts->[4]; | |
$env->{CONTENT_TYPE} = $parts->[5]; | |
$env->{CONTENT_LENGTH} = $parts->[6]; | |
$env->{CONTENT_LENGTH} = $parts->[6]; | |
$env->{HTTP_COOKIE} = $parts->[7]; | |
$env->{REMOTE_ADDR} = $parts->[8]; | |
( $env->{REQUEST_URI}, $env->{QUERY_STRING} ) = split( /\?/, $parts->[9] ); | |
$env->{PATH_INFO} = $env->{REQUEST_URI}; | |
$env->{SCRIPT_NAME} = ''; | |
$env->{"psgi.url_scheme"} = 'http'; # TODO | |
open( my $fh, '<', \$parts->[10] ); | |
$env->{"psgi.input"} = $fh; | |
$env->{"psgi.input.buffered"} = $fh; | |
return $env; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment