[PATCH 2 of 3] Tests: SCGI tests for non-buffered and discarded request body
Maxim Dounin
mdounin at mdounin.ru
Sat May 9 21:02:37 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1778251045 -10800
# Fri May 08 17:37:25 2026 +0300
# Node ID 20878a3be12b6ff597e952432f6e8f18fbec549a
# Parent e5409c48dce25d4d5fe234de8a5f4f4ff9efcee7
Tests: SCGI tests for non-buffered and discarded request body.
diff --git a/scgi_body.t b/scgi_body.t
--- a/scgi_body.t
+++ b/scgi_body.t
@@ -24,7 +24,7 @@ select STDOUT; $| = 1;
eval { require SCGI; };
plan(skip_all => 'SCGI not installed') if $@;
-my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(5)
+my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(7)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -46,6 +46,18 @@ http {
scgi_param SCGI 1;
scgi_param REQUEST_URI $request_uri;
}
+
+ location /nb/ {
+ scgi_pass 127.0.0.1:8081;
+ scgi_param SCGI 1;
+ scgi_param REQUEST_URI $request_uri;
+ scgi_request_buffering off;
+ }
+
+ location /discard/ {
+ client_max_body_size 1;
+ error_page 413 /error413;
+ }
}
}
@@ -65,6 +77,17 @@ like(http_get_length('/', ''), qr/X-Body
like(http_get_chunked('/', 'foobar'), qr/X-Body: 'foobar'/, 'scgi chunked');
like(http_get_chunked('/', ''), qr/X-Body: ''/, 'scgi empty chunked');
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.31.1');
+
+like(http_get_nobuf('/nb/', 'foo', 'bar'), qr/X-Body: 'foobar'/,
+ 'scgi no request buffering');
+
+}
+
+like(http_get_nobuf('/discard/', 'foo', 'bar'), qr/X-Body: ''/,
+ 'scgi discard body');
+
###############################################################################
sub http_get_length {
@@ -96,6 +119,18 @@ 0
EOF
}
+sub http_get_nobuf {
+ my ($url, $body1, $body2) = @_;
+ my $length = length($body1) + length($body2);
+ return http(<<EOF . $body1, sleep => 0.1, body => $body2);
+GET $url HTTP/1.1
+Host: localhost
+Connection: close
+Content-Length: $length
+
+EOF
+}
+
###############################################################################
sub scgi_daemon {
More information about the nginx-devel
mailing list