AWS-Lambda

 view release on metacpan or  search on metacpan

examples/cgi/WwwCounter/gifcat.pl  view on Meta::CPAN

	return(substr($buf, $from, $cnt - $from));
}

;# =====================================
;# Memory Dump
;# =====================================
sub Dump {
	local($buf) = @_;
	my($i);

	if (length($buf) == 0) {
		return;
	}
	for ($i = 0; $i < length($buf); $i++) {
		if (($i % 16) == 0) {
			printf("  ");
		}
		printf("%02X ", ord(substr($buf, $i, 1)));
		if (($i % 16) == 15) {
			printf("\n");
		}
	}
	if (($i % 16) != 0) {
		printf("\n");

examples/cgi/WwwCounter/readme.html  view on Meta::CPAN

<p>隠しカウンタのカウント数は、レポート機能や、wwwcount.cnt ファイルを直接参照することで確認できます。</p>
</div>

<h4>■ <a name="RefFind">リンク元発見機能</a></h4>
<div class=i>
<p>CGIグラフィックカウンターを以下のように呼び出すと、自分のホームページがどこからリンクされているのか発見することができます。</p>
<pre class=c>
&lt;script&gt;
xx = escape(document.referrer);
yy = "";
for (i = 0; i &lt; xx.length; i++) {
  zz = xx.charAt(i);
  yy += (zz == "+") ? "%2B" : zz;
}
document.write('&lt;img width=96 height=19 ');
document.write('src="wwwcount.cgi?gif');
document.write('+ref+', yy, '"&gt;');
&lt;/script&gt;
&lt;noscript&gt;
&lt;img width=96 height=19 src="wwwcount.cgi?gif"&gt;
&lt;/noscript&gt;

examples/cgi/WwwCounter/wwwcount.cgi  view on Meta::CPAN

	if ($g_mode eq "text") {
		printf("Content-type: text/html\n");
		printf("\n");
		printf("$count_str\n");

	# GIFモード
	} elsif ($g_mode eq "gif") {
		printf("Content-type: image/gif\n");
		printf("\n");
		@files = ();
		for (my $i = 0; $i < length($count_str); $i++) {
			$n = substr($count_str, $i, 1);
			push(@files, "$n.gif");
		}
		require "./gifcat.pl";
		binmode(STDOUT);
		print gifcat'gifcat(@files);

	# 隠しカウンターモード
	} elsif ($g_mode eq "hide") {
		printf("Content-type: image/gif\n");

lib/AWS/Lambda/PSGI.pm  view on Meta::CPAN

        $env->{'HTTP_X_REQUEST_ID'} = $ctx->aws_request_id;
    }

    my $body = encode_utf8($payload->{body} // '');
    if ($payload->{isBase64Encoded}) {
        $body = decode_base64 $body;
    }
    open my $input, "<", \$body;
    $env->{REQUEST_METHOD} = $payload->{httpMethod};
    $env->{'psgi.input'} = $input;
    $env->{CONTENT_LENGTH} //= bytes::length($body);
    $env->{REQUEST_URI} = $payload->{path};
    if ($env->{QUERY_STRING}) {
        $env->{REQUEST_URI} .= '?' . $env->{QUERY_STRING};
    }
    $env->{PATH_INFO} = URI::Escape::uri_unescape($payload->{path});

    $env->{SCRIPT_NAME} = '';
    my $requestContext = $payload->{requestContext};
    if ($requestContext) {
        my $path = $requestContext->{path};

lib/AWS/Lambda/PSGI.pm  view on Meta::CPAN

        $env->{'psgix.request_id'} = $ctx->aws_request_id;
        $env->{'HTTP_X_REQUEST_ID'} = $ctx->aws_request_id;
    }

    my $body = encode_utf8($payload->{body} // '');
    if ($payload->{isBase64Encoded}) {
        $body = decode_base64 $body;
    }
    open my $input, "<", \$body;
    $env->{'psgi.input'} = $input;
    $env->{CONTENT_LENGTH} //= bytes::length($body);
    my $requestContext = $payload->{requestContext};
    $env->{REQUEST_METHOD} = $requestContext->{http}{method};
    $env->{REQUEST_URI} = $payload->{rawPath};
    if ($env->{QUERY_STRING}) {
        $env->{REQUEST_URI} .= '?' . $env->{QUERY_STRING};
    }
    $env->{PATH_INFO} = $requestContext->{http}{path};
    $env->{SCRIPT_NAME} = '';
    return $env;
}

lib/AWS/Lambda/ResponseWriter.pm  view on Meta::CPAN

        $self->close;
    }

    my $http = $self->{http};
    my $handle = $self->{handle};
    my $response;
    do { $response = $handle->read_response_header }
        until (substr($response->{status},0,1) ne '1');

    my $data_cb = $http->_prepare_data_cb($response, {});
    my $known_message_length = $handle->read_body($data_cb, $response);
    $handle->close;

    $response->{success} = substr( $response->{status}, 0, 1 ) eq '2';
    $response->{url} = $self->{response_url};
    return $response;
}

sub write {
    my ($self, $data) = @_;

    if ($self->{closed}) {
        # already closed
        croak "write failed: already closed";
    }

    if (!defined($data) || length($data) == 0) {
        return "0E0";
    }

    my $chunk  = sprintf '%X', length $data;
    $chunk .= "\x0D\x0A";
    $chunk .= $data;
    $chunk .= "\x0D\x0A";
    return $self->{handle}->write($chunk);
}

sub close {
    my $self = shift;
    if ($self->{closed}) {
        # already closed

t/testdata/alb-base64-request.json  view on Meta::CPAN

    "requestContext": {
        "elb": {
            "targetGroupArn": "arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:targetgroup/lambda-target/a8d0882e91e66540"
        }
    },
    "httpMethod": "POST",
    "path": "/foo/bar",
    "queryStringParameters": {},
    "headers": {
        "accept": "*/*",
        "content-length": "17",
        "content-type": "application/octet-stream",
        "host": "lambda-test-1234567890.ap-northeast-1.elb.amazonaws.com",
        "user-agent": "curl/7.54.0",
        "x-amzn-trace-id": "Root=1-5c0f091f-56087f0297986bc017de21bc",
        "x-forwarded-for": "192.0.2.1",
        "x-forwarded-port": "80",
        "x-forwarded-proto": "http"
    },
    "body": "eyJoZWxsbyI6IndvcmxkIn0=",
    "isBase64Encoded": true

t/testdata/alb-post-request.json  view on Meta::CPAN

    "requestContext": {
        "elb": {
            "targetGroupArn": "arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:targetgroup/lambda-target/a8d0882e91e66540"
        }
    },
    "httpMethod": "POST",
    "path": "/",
    "queryStringParameters": {},
    "headers": {
        "accept": "*/*",
        "content-length": "17",
        "content-type": "application/json",
        "host": "lambda-test-1234567890.ap-northeast-1.elb.amazonaws.com",
        "user-agent": "curl/7.54.0",
        "x-amzn-trace-id": "Root=1-5c0f08ec-8a00ddf3c79b53a01fa905ba",
        "x-forwarded-for": "192.0.2.1",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "body": "{\"hello\":\"こんにちは世界\"}",
    "isBase64Encoded": false

t/testdata/apigateway-v2-base64-request.json  view on Meta::CPAN

{
    "version": "2.0",
    "routeKey": "$default",
    "rawPath": "/my/path",
    "rawQueryString": "",
    "headers": {
        "accept": "*/*",
        "content-length": "17",
        "content-type": "application/octet-stream",
        "host": "xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com",
        "user-agent": "curl/7.64.1",
        "x-amzn-trace-id": "Root=1-5e8a9b8c-5fd89a5053994a40c1343990",
        "x-forwarded-for":  "192.0.2.1",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "requestContext": {
        "accountId": "123456789012",

t/testdata/apigateway-v2-get-request.json  view on Meta::CPAN

{
    "version": "2.0",
    "routeKey": "$default",
    "rawPath": "/my/path",
    "rawQueryString": "parameter1=value1&parameter1=value2&parameter2=value",
    "headers": {
        "accept": "*/*",
        "content-length": "0",
        "header1": "value1,value2",
        "header2": "value2",
        "host": "xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com",
        "user-agent": "curl/7.64.1",
        "x-amzn-trace-id": "Root=1-5e8a9a35-1d1dea5e28ab3c9c2a525afc",
        "x-forwarded-for": "192.0.2.1",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "queryStringParameters": {

t/testdata/apigateway-v2-post-request.json  view on Meta::CPAN

{
    "version": "2.0",
    "routeKey": "$default",
    "rawPath": "/my/path",
    "rawQueryString": "",
    "headers": {
        "accept": "*/*",
        "content-length": "17",
        "content-type": "application/json",
        "host": "xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com",
        "user-agent": "curl/7.64.1",
        "x-amzn-trace-id": "Root=1-5e8a9af6-43dfdbb5896d7684515eb0ba",
        "x-forwarded-for": "192.0.2.1",
        "x-forwarded-port": "443",
        "x-forwarded-proto": "https"
    },
    "requestContext": {
        "accountId": "123456789012",



( run in 0.620 second using v1.01-cache-2.11-cpan-65fba6d93b7 )