rc = ctx->engine->call((ngx_js_ctx_t *) ctx, &jlcf->body_filter,
(njs_opaque_value_t *) &arguments[0], 3);
- JS_FreeAtom(cx, last_key);
JS_FreeValue(cx, arguments[1]);
JS_FreeValue(cx, arguments[2]);
if (rc == NGX_ERROR) {
+ JS_FreeAtom(cx, last_key);
return NGX_ERROR;
}
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"async operation inside \"%V\" body filter",
&jlcf->body_filter);
+ JS_FreeAtom(cx, last_key);
return NGX_ERROR;
}
} else {
cl = ngx_alloc_chain_link(c->pool);
if (cl == NULL) {
+ JS_FreeAtom(cx, last_key);
return NGX_ERROR;
}
in = in->next;
}
+ JS_FreeAtom(cx, last_key);
+
return NGX_OK;
}
###############################################################################
+sub send_chunked {
+ my ($client, @chunks) = @_;
+
+ print $client
+ "HTTP/1.1 200 OK" . CRLF .
+ "Transfer-Encoding: chunked" . CRLF .
+ "Connection: close" . CRLF .
+ CRLF;
+
+ for my $chunk (@chunks) {
+ printf $client "%x\r\n%s\r\n", length($chunk), $chunk;
+ }
+
+ print $client "0\r\n\r\n";
+}
+
sub http_daemon {
my $port = shift;
- my $delay = shift || 0.05;
my $server = IO::Socket::INET->new(
Proto => 'tcp',
log2c("(new connection $client $uri)");
if ($uri eq '/source') {
- print $client
- "HTTP/1.1 200 OK" . CRLF .
- "Content-Length: 10" . CRLF .
- "Connection: close" . CRLF .
- CRLF;
-
- print $client "AAA";
- select undef, undef, undef, $delay;
- print $client "BB";
- select undef, undef, undef, $delay;
- print $client "C";
- select undef, undef, undef, $delay;
- print $client "DDDD";
-
- } elsif ($uri eq '/nonutf8_source') {
- print $client
- "HTTP/1.1 200 OK" . CRLF .
- "Content-Length: 6" . CRLF .
- "Connection: close" . CRLF .
- CRLF;
+ send_chunked($client, "AAA", "BB", "C", "DDDD");
- print $client "\xaa\xaa";
- select undef, undef, undef, $delay;
- print $client "\xbb";
- select undef, undef, undef, $delay;
- print $client "\xcc";
- select undef, undef, undef, $delay;
- print $client "\xdd\xdd";
+ } elsif ($uri eq '/nonutf8_source') {
+ send_chunked($client, "\xaa\xaa", "\xbb", "\xcc", "\xdd\xdd");
} else {
print $client