[nginx-tests] Tests: tests for request body chunked extensions a...

Maxim Dounin mdounin at mdounin.ru
Sat Mar 30 05:08:35 UTC 2024


details:   http://freenginx.org/hg/nginx-tests/rev/5cf0e07d63a1
branches:  
changeset: 1954:5cf0e07d63a1
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Sat Mar 30 07:48:42 2024 +0300
description:
Tests: tests for request body chunked extensions and trailers.

diffstat:

 body_chunked.t |  65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 1 deletions(-)

diffs (96 lines):

diff --git a/body_chunked.t b/body_chunked.t
--- a/body_chunked.t
+++ b/body_chunked.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(18);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(24);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -68,6 +68,7 @@ http {
         }
         location /large {
             client_max_body_size 1k;
+            client_body_buffer_size 2k;
             proxy_pass http://127.0.0.1:8081;
         }
         location /discard {
@@ -119,6 +120,8 @@ like(http_get_body('/single', '012345678
 	qr/X-Body: (0123456789){128}\x0d?$/ms, 'body in single buffer');
 
 like(http_get_body('/large', '0123456789' x 128), qr/ 413 /, 'body too large');
+like(http_get_body('/large', 'X' x 1024), qr/ 200 /, 'body exact limit');
+like(http_get_body('/large', 'X' x 1025), qr/ 413 /, 'body just above limit');
 
 # pipelined requests
 
@@ -162,6 +165,66 @@ like(
 	qr/400 Bad/, 'runaway chunk discard'
 );
 
+# chunk extensions and trailers
+
+like(
+	http(
+		'GET /large HTTP/1.1' . CRLF
+		. 'Host: localhost' . CRLF
+		. 'Connection: close' . CRLF
+		. 'Transfer-Encoding: chunked' . CRLF . CRLF
+		. ('1; foo' . CRLF . 'X' . CRLF) x 16
+		. '0' . CRLF . CRLF
+	),
+	qr/ 200 /, 'chunk extensions'
+);
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.25.5');
+
+like(
+	http(
+		'GET /large HTTP/1.1' . CRLF
+		. 'Host: localhost' . CRLF
+		. 'Connection: close' . CRLF
+		. 'Transfer-Encoding: chunked' . CRLF . CRLF
+		. ('1; foo' . CRLF . 'X' . CRLF) x 512
+		. '0' . CRLF . CRLF
+	),
+	qr/ 413 /, 'too many chunk extensions'
+);
+
+}
+
+like(
+	http(
+		'GET /large HTTP/1.1' . CRLF
+		. 'Host: localhost' . CRLF
+		. 'Connection: close' . CRLF
+		. 'Transfer-Encoding: chunked' . CRLF . CRLF
+		. '1' . CRLF . 'X' . CRLF
+		. '0' . CRLF . ('X-Trailer: foo' . CRLF) x 16 . CRLF
+	),
+	qr/ 200 /, 'trailers'
+);
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.25.5');
+
+like(
+	http(
+		'GET /large HTTP/1.1' . CRLF
+		. 'Host: localhost' . CRLF
+		. 'Connection: close' . CRLF
+		. 'Transfer-Encoding: chunked' . CRLF . CRLF
+		. '1' . CRLF . 'X' . CRLF
+		. '0' . CRLF . ('X-Trailer: foo' . CRLF) x 512 . CRLF
+	),
+	qr/ 413 /, 'too many trailers'
+);
+
+}
+
 # proxy_next_upstream
 
 like(http_get_body('/next', '0123456789'),



More information about the nginx-devel mailing list