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 d09dcc2
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 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 Down Expand Up @@ -87,7 +87,7 @@ 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};",
}
]

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

class TransformHeadersInLC(tester.TempestaTest):
'''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.
'''

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

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,
}

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)))

0 comments on commit d09dcc2

Please sign in to comment.