[PATCH 3 of 3] Tests: uwsgi tests for non-buffered and discarded request body

Maxim Dounin mdounin at mdounin.ru
Sat May 9 21:02:38 UTC 2026


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1778251716 -10800
#      Fri May 08 17:48:36 2026 +0300
# Node ID b4abfc864a24f2d06bcab10a89655a47b19562e3
# Parent  20878a3be12b6ff597e952432f6e8f18fbec549a
Tests: uwsgi tests for non-buffered and discarded request body.

diff --git a/uwsgi_body.t b/uwsgi_body.t
--- a/uwsgi_body.t
+++ b/uwsgi_body.t
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 
+# (C) Maxim Dounin
 # (C) Sergey Kandaurov
 # (C) Nginx, Inc.
 
@@ -23,7 +24,7 @@ select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
 my $t = Test::Nginx->new()->has(qw/http rewrite uwsgi/)
-	->has_daemon('uwsgi')->plan(5)
+	->has_daemon('uwsgi')->plan(7)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -46,6 +47,17 @@ http {
             uwsgi_pass 127.0.0.1:8081;
             uwsgi_param CONTENT_LENGTH $content_length if_not_empty;
         }
+
+        location /nb/ {
+            uwsgi_pass 127.0.0.1:8081;
+            uwsgi_param CONTENT_LENGTH $content_length if_not_empty;
+            uwsgi_request_buffering off;
+        }
+
+        location /discard/ {
+            client_max_body_size 1;
+            error_page 413 /error413;
+        }
     }
 }
 
@@ -95,6 +107,12 @@ like(http_get_length('/', ''), qr/cl=0 '
 like(http_get_chunked('/', 'foobar'), qr/cl=6 'foobar'/, 'uwsgi chunked');
 like(http_get_chunked('/', ''), qr/cl=0 ''/, 'uwsgi empty chunked');
 
+like(http_get_nobuf('/', 'foo', 'bar'), qr/cl=6 'foobar'/,
+	'uwsgi no request buffering');
+
+like(http_get_nobuf('/discard/', 'foo', 'bar'), qr/SEE-THIS/,
+	'uwsgi discard body');
+
 ###############################################################################
 
 sub http_get_length {
@@ -126,4 +144,16 @@ 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
+}
+
 ###############################################################################



More information about the nginx-devel mailing list