Skip to content

Commit

Permalink
test for converting header field names to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
avbelov23 committed Sep 23, 2020
1 parent 4c30a47 commit 65bb7a6
Showing 1 changed file with 92 additions and 3 deletions.
95 changes: 92 additions & 3 deletions h2/test_h2_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
listen ${server_ip}:8000;
location / {
root ${server_resources};
%s
}
location /nginx_status {
stub_status on;
Expand All @@ -63,6 +63,7 @@
proxy_pass default;
}
%s
"""

class HeadersParsing(tester.TempestaTest):
Expand All @@ -87,12 +88,12 @@ class HeadersParsing(tester.TempestaTest):
'type' : 'nginx',
'port' : '8000',
'status_uri' : 'http://${server_ip}:8000/nginx_status',
'config' : NGINX_CONFIG,
'config' : NGINX_CONFIG % "root ${server_resources};",
}
]

tempesta = {
'config' : TEMPESTA_CONFIG,
'config' : TEMPESTA_CONFIG % "",
}

def test_random_header(self):
Expand All @@ -106,3 +107,91 @@ def test_random_header(self):
self.start_tempesta()
self.start_all_clients()
self.wait_while_busy(curl)

class CurlTest(tester.TempestaTest):

clients = [
{
'id' : 'curl',
'type' : 'external',
'binary' : 'curl',
'cmd_args' : (
'-k '
'https://${tempesta_ip}/ '
)
},
]

def test(self):
curl = self.get_client('curl')

self.start_all_servers()
self.start_tempesta()
self.start_all_clients()
self.wait_while_busy(curl)

self.assertEqual(0, curl.returncode,
msg=("Curl return code is not 0 (%d)." %
(curl.returncode)))

class TransformHeadersInLC(CurlTest):
'''https://tools.ietf.org/html/rfc7540#section-8.1.2
Just as in HTTP/1.x, header field names are strings of ASCII
characters that are compared in a case-insensitive fashion. However,
header field names MUST be converted to lowercase prior to their
encoding in HTTP/2. A request or response containing uppercase
header field names MUST be treated as malformed.
Ask curl to make an h2 request, if header field names are not converted to
lowercase then curl return code is not 0.
'''

backends = [
{
'id' : 'nginx',
'type' : 'nginx',
'port' : '8000',
'status_uri' : 'http://${server_ip}:8000/nginx_status',
'config' : NGINX_CONFIG % """
add_header X-Extra-Data1 "q";
add_header X-Extra-Data2 "q";
add_header X-Extra-Data1 "q";
return 200;
""",
}
]

tempesta = {
'config' : TEMPESTA_CONFIG % "",
}

class TransformHeadersInLCCache(CurlTest):
'''https://tools.ietf.org/html/rfc7540#section-8.1.2
Just as in HTTP/1.x, header field names are strings of ASCII
characters that are compared in a case-insensitive fashion. However,
header field names MUST be converted to lowercase prior to their
encoding in HTTP/2. A request or response containing uppercase
header field names MUST be treated as malformed.
Ask curl to make an h2 request, if header field names are not converted to
lowercase then curl return code is not 0.
'''

backends = [
{
'id' : 'nginx',
'type' : 'nginx',
'port' : '8000',
'status_uri' : 'http://${server_ip}:8000/nginx_status',
'config' : NGINX_CONFIG % """
add_header X-Extra-Data1 "q";
add_header X-Extra-Data2 "q";
add_header X-Extra-Data1 "q";
return 200;
""",
}
]

tempesta = {
'config' : TEMPESTA_CONFIG % "cache_fulfill * *;",
}

0 comments on commit 65bb7a6

Please sign in to comment.