def testComplexGET(self): data = b"""\ GET /foo/a+%2B%2F%C3%A4%3D%26a%3Aint?d=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6 HTTP/8.4 FirstName: mickey lastname: Mouse content-length: 10 Hello mickey. """ parser = self.parser self.feed(data) self.assertEqual(parser.command, 'GET') self.assertEqual(parser.version, '8.4') self.assertFalse(parser.empty) self.assertEqual(parser.headers, { 'FIRSTNAME': 'mickey', 'LASTNAME': 'Mouse', 'CONTENT_LENGTH': '10', }) # path should be utf-8 encoded self.assertEqual( tobytes(parser.path).decode('utf-8'), text_(b'/foo/a++/\xc3\xa4=&a:int', 'utf-8')) self.assertEqual(parser.query, 'd=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6') self.assertEqual(parser.get_body_stream().getvalue(), b'Hello mick')
def testComplexGET(self): data = ( b"GET /foo/a+%2B%2F%C3%A4%3D%26a%3Aint?d=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6 HTTP/8.4\r\n" b"FirstName: mickey\r\n" b"lastname: Mouse\r\n" b"content-length: 10\r\n" b"\r\n" b"Hello mickey.") parser = self.parser self.feed(data) self.assertEqual(parser.command, "GET") self.assertEqual(parser.version, "8.4") self.assertFalse(parser.empty) self.assertEqual( parser.headers, { "FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "10" }, ) # path should be utf-8 encoded self.assertEqual( tobytes(parser.path).decode("utf-8"), text_(b"/foo/a++/\xc3\xa4=&a:int", "utf-8"), ) self.assertEqual(parser.query, "d=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6") self.assertEqual(parser.get_body_stream().getvalue(), b"Hello mick")
def testComplexGET(self): data = b"""\ GET /foo/a+%2B%2F%C3%A4%3D%26a%3Aint?d=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6 HTTP/8.4 FirstName: mickey lastname: Mouse content-length: 10 Hello mickey. """ parser = self.parser self.feed(data) self.assertEqual(parser.command, 'GET') self.assertEqual(parser.version, '8.4') self.assertFalse(parser.empty) self.assertEqual(parser.headers, {'FIRSTNAME': 'mickey', 'LASTNAME': 'Mouse', 'CONTENT_LENGTH': '10', }) # path should be utf-8 encoded self.assertEqual(tobytes(parser.path).decode('utf-8'), text_(b'/foo/a++/\xc3\xa4=&a:int', 'utf-8')) self.assertEqual(parser.query, 'd=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6') self.assertEqual(parser.get_body_stream().getvalue(), b'Hello mick')
def testComplexGET(self): data = b"""\ GET /foo/a+%2B%2F%C3%A4%3D%26a%3Aint?d=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6 HTTP/8.4 FirstName: mickey lastname: Mouse content-length: 10 Hello mickey. """ parser = self.parser self.feed(data) self.assertEqual(parser.command, "GET") self.assertEqual(parser.version, "8.4") self.assertFalse(parser.empty) self.assertEqual(parser.headers, {"FIRSTNAME": "mickey", "LASTNAME": "Mouse", "CONTENT_LENGTH": "10"}) # path should be utf-8 encoded self.assertEqual(tobytes(parser.path).decode("utf-8"), text_(b"/foo/a++/\xc3\xa4=&a:int", "utf-8")) self.assertEqual(parser.query, "d=b+%2B%2F%3D%26b%3Aint&c+%2B%2F%3D%26c%3Aint=6") self.assertEqual(parser.get_body_stream().getvalue(), b"Hello mick")