Welcome! Log In Create A New Profile

Advanced

[PATCH] Tests: HTTP/2 tests with error_page and return

Sergey Kandaurov
May 01, 2023 10:48AM
# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1682952238 -14400
# Mon May 01 18:43:58 2023 +0400
# Node ID 90aaa942972884dcd67b6744fde39a154fec5d13
# Parent 36a4563f7f005184547575f5ac4f22ef53a59c72
Tests: HTTP/2 tests with error_page and return.

diff --git a/h2_error_page.t b/h2_error_page.t
new file mode 100644
--- /dev/null
+++ b/h2_error_page.t
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+
+# (C) Sergey Kandaurov
+# (C) Nginx, Inc.
+
+# Tests for HTTP/2 protocol with error_page directive.
+
+###############################################################################
+
+use warnings;
+use strict;
+
+use Test::More;
+
+BEGIN { use FindBin; chdir($FindBin::Bin); }
+
+use lib 'lib';
+use Test::Nginx;
+use Test::Nginx::HTTP2;
+
+###############################################################################
+
+select STDERR; $| = 1;
+select STDOUT; $| = 1;
+
+my $t = Test::Nginx->new()->has(qw/http http_v2 rewrite/)->plan(2)
+ ->write_file_expand('nginx.conf', <<'EOF');
+
+%%TEST_GLOBALS%%
+
+daemon off;
+
+events {
+}
+
+http {
+ %%TEST_GLOBALS_HTTP%%
+
+ server {
+ listen 127.0.0.1:8080 http2;
+ server_name localhost;
+
+ lingering_close off;
+
+ error_page 400 = /close;
+
+ location / { }
+
+ location /close {
+ return 444;
+ }
+ }
+}
+
+EOF
+
+$t->run();
+
+###############################################################################
+
+my ($sid, $frames, $frame);
+
+# tests for socket leak with "return 444" in error_page
+
+# ticket #274
+
+my $s1 = Test::Nginx::HTTP2->new();
+$sid = $s1->new_stream({ headers => [
+ { name => ':method', value => 'GET' },
+ { name => ':path', value => '/' },
+ { name => ':authority', value => 'localhost' }]});
+$frames = $s1->read(all => [{ type => 'RST_STREAM' }]);
+
+($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
+is($frame->{sid}, $sid, 'error 400 return 444 - missing header');
+
+# ticket #2455
+
+my $s2 = Test::Nginx::HTTP2->new();
+$sid = $s2->new_stream({ method => 'foo' });
+$frames = $s2->read(all => [{ type => 'RST_STREAM' }]);
+
+($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
+is($frame->{sid}, $sid, 'error 400 return 444 - invalid header');
+
+$t->stop();
+
+###############################################################################
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Tests: HTTP/2 tests with error_page and return

Sergey Kandaurov 426 May 01, 2023 10:48AM

Re: [PATCH] Tests: HTTP/2 tests with error_page and return

Maxim Dounin 91 May 01, 2023 05:00PM

Re: [PATCH] Tests: HTTP/2 tests with error_page and return

Sergey Kandaurov 104 May 02, 2023 09:12AM

Re: [PATCH] Tests: HTTP/2 tests with error_page and return

Maxim Dounin 84 May 02, 2023 05:46PM

Re: [PATCH] Tests: HTTP/2 tests with error_page and return

Sergey Kandaurov 111 May 11, 2023 07:32AM

Re: [PATCH] Tests: HTTP/2 tests with error_page and return

Maxim Dounin 94 May 18, 2023 12:10PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 136
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready