HTTP parser: fixed parsing of target after literal space character.

In theory, all space characters in request target must be encoded; however,
some clients may violate the specification.  For the sake of interoperability,
Unit supports unencoded space characters.

Previously, if there was a space character before the extension or arguments
parts, those parts weren't recognized.  Also, quoted symbols and complex
target weren't detected after a space character.
This commit is contained in:
Valentin Bartenev
2019-09-17 18:40:21 +03:00
parent 3b77e402a9
commit 6352c21a58
3 changed files with 63 additions and 3 deletions

View File

@@ -71,6 +71,37 @@ class TestPythonApplication(TestApplicationPython):
'Query-String header',
)
def test_python_application_query_string_space(self):
self.load('query_string')
resp = self.get(url='/ ?var1=val1&var2=val2')
self.assertEqual(
resp['headers']['Query-String'],
'var1=val1&var2=val2',
'Query-String space',
)
resp = self.get(url='/ %20?var1=val1&var2=val2')
self.assertEqual(
resp['headers']['Query-String'],
'var1=val1&var2=val2',
'Query-String space 2',
)
resp = self.get(url='/ %20 ?var1=val1&var2=val2')
self.assertEqual(
resp['headers']['Query-String'],
'var1=val1&var2=val2',
'Query-String space 3',
)
resp = self.get(url='/blah %20 blah? var1= val1 & var2=val2')
self.assertEqual(
resp['headers']['Query-String'],
' var1= val1 & var2=val2',
'Query-String space 4',
)
def test_python_application_query_string_empty(self):
self.load('query_string')