From 2c36981c8b182562c0cd0f7bf901f09002432360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 14:42:40 +0100 Subject: [PATCH 01/11] [feature/use_hex_encoding] --- mocket/async_mocket.py | 8 +++++++- mocket/inject.py | 2 ++ mocket/mocket.py | 5 +++++ mocket/mocketizer.py | 19 ++++++++++++++++-- mocket/socket.py | 44 ++++++++++++++++++++++++++++++++++-------- 5 files changed, 67 insertions(+), 11 deletions(-) diff --git a/mocket/async_mocket.py b/mocket/async_mocket.py index 709d225f..da3ba35a 100644 --- a/mocket/async_mocket.py +++ b/mocket/async_mocket.py @@ -7,11 +7,17 @@ async def wrapper( truesocket_recording_dir=None, strict_mode=False, strict_mode_allowed=None, + use_hex_encoding=True, *args, **kwargs, ): async with Mocketizer.factory( - test, truesocket_recording_dir, strict_mode, strict_mode_allowed, args + test, + truesocket_recording_dir, + strict_mode, + strict_mode_allowed, + use_hex_encoding, + args, ): return await test(*args, **kwargs) diff --git a/mocket/inject.py b/mocket/inject.py index cba0b40b..b8c27d01 100644 --- a/mocket/inject.py +++ b/mocket/inject.py @@ -41,6 +41,7 @@ def enable( namespace: str | None = None, truesocket_recording_dir: str | None = None, + use_hex_encoding=True, ) -> None: from mocket.mocket import Mocket from mocket.socket import MocketSocket, create_connection, socketpair @@ -48,6 +49,7 @@ def enable( Mocket._namespace = namespace Mocket._truesocket_recording_dir = truesocket_recording_dir + Mocket._use_hex_encoding = use_hex_encoding if truesocket_recording_dir and not os.path.isdir(truesocket_recording_dir): # JSON dumps will be saved here diff --git a/mocket/mocket.py b/mocket/mocket.py index 3476902d..bbb7feb1 100644 --- a/mocket/mocket.py +++ b/mocket/mocket.py @@ -22,6 +22,7 @@ class Mocket: _requests: ClassVar[list] = [] _namespace: ClassVar[str] = str(id(_entries)) _truesocket_recording_dir: ClassVar[str | None] = None + _use_hex_encoding: ClassVar[bool] = True enable = mocket.inject.enable disable = mocket.inject.disable @@ -96,6 +97,10 @@ def get_namespace(cls) -> str: def get_truesocket_recording_dir(cls) -> str | None: return cls._truesocket_recording_dir + @classmethod + def get_use_hex_encoding(cls) -> bool: + return cls._use_hex_encoding + @classmethod def assert_fail_if_entries_not_served(cls) -> None: """Mocket checks that all entries have been served at least once.""" diff --git a/mocket/mocketizer.py b/mocket/mocketizer.py index 2bf2b9cd..cfcaf471 100644 --- a/mocket/mocketizer.py +++ b/mocket/mocketizer.py @@ -9,6 +9,7 @@ def __init__( instance=None, namespace=None, truesocket_recording_dir=None, + use_hex_encoding=True, strict_mode=False, strict_mode_allowed=None, ): @@ -57,7 +58,14 @@ def check_and_call(self, method_name): method() @staticmethod - def factory(test, truesocket_recording_dir, strict_mode, strict_mode_allowed, args): + def factory( + test, + truesocket_recording_dir, + strict_mode, + strict_mode_allowed, + use_hex_encoding, + args, + ): instance = args[0] if args else None namespace = None if truesocket_recording_dir: @@ -74,6 +82,7 @@ def factory(test, truesocket_recording_dir, strict_mode, strict_mode_allowed, ar namespace=namespace, truesocket_recording_dir=truesocket_recording_dir, strict_mode=strict_mode, + use_hex_encoding=use_hex_encoding, strict_mode_allowed=strict_mode_allowed, ) @@ -83,11 +92,17 @@ def wrapper( truesocket_recording_dir=None, strict_mode=False, strict_mode_allowed=None, + use_hex_encoding=True, *args, **kwargs, ): with Mocketizer.factory( - test, truesocket_recording_dir, strict_mode, strict_mode_allowed, args + test, + truesocket_recording_dir, + strict_mode, + strict_mode_allowed, + use_hex_encoding, + args, ): return test(*args, **kwargs) diff --git a/mocket/socket.py b/mocket/socket.py index e4be00b6..41a718e4 100644 --- a/mocket/socket.py +++ b/mocket/socket.py @@ -1,8 +1,11 @@ import contextlib import errno +import gzip import hashlib import json +import logging import os +import re import select import socket import ssl @@ -20,6 +23,8 @@ from mocket.mode import MocketMode from mocket.utils import hexdump, hexload + +logger = logging.getLogger(__name__) xxh32 = None try: from xxhash import xxh32 @@ -263,7 +268,20 @@ def true_sendall(self, data, *args, **kwargs): # try to get the response from the dictionary try: - encoded_response = hexload(response_dict["response"]) + response = response_dict["response"] + + if Mocket.get_use_hex_encoding(): + encoded_response = hexload(response) + else: + headers, body = response.split("\r\n\r\n", 1) + + headers_bytes = headers.encode("utf-8") + body_bytes = body.encode("utf-8") + + if "content-encoding: gzip" in headers.lower(): + body_bytes = gzip.compress(body_bytes) + + encoded_response = headers_bytes + b"\r\n\r\n" + body_bytes # if not available, call the real sendall except KeyError: host, port = self._host, self._port @@ -290,17 +308,27 @@ def true_sendall(self, data, *args, **kwargs): break encoded_response += new_content - # dump the resulting dictionary to a JSON file if Mocket.get_truesocket_recording_dir(): - # update the dictionary with request and response lines - response_dict["request"] = req - response_dict["response"] = hexdump(encoded_response) + # dump the resulting dictionary to a JSON file + if Mocket.get_use_hex_encoding(): + response_dict["response"] = hexdump(encoded_response) + else: + try: + headers, body = encoded_response.split(b"\r\n\r\n", 1) + + if b"content-encoding: gzip" in headers.lower(): + body = gzip.decompress(body) + + response_dict["response"] = (headers + b"\r\n\r\n" + body).decode( + "utf-8" + ) + + except UnicodeDecodeError as e: + logger.warning("Mocket: Response not recorded: %s", e) with open(path, mode="w") as f: f.write( - decode_from_bytes( - json.dumps(responses, indent=4, sort_keys=True) - ) + decode_from_bytes(json.dumps(responses, indent=4, sort_keys=True)) ) # response back to .sendall() which writes it to the Mocket socket and flush the BytesIO From a384a26ec71212dabf8d874c16b2439d78ca97e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 15:10:52 +0100 Subject: [PATCH 02/11] [feature/use_hex_encoding] --- mocket/mocketizer.py | 2 ++ tests/test_http.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/mocket/mocketizer.py b/mocket/mocketizer.py index cfcaf471..4d00805f 100644 --- a/mocket/mocketizer.py +++ b/mocket/mocketizer.py @@ -15,6 +15,7 @@ def __init__( ): self.instance = instance self.truesocket_recording_dir = truesocket_recording_dir + self.use_hex_encoding = use_hex_encoding self.namespace = namespace or str(id(self)) MocketMode().STRICT = strict_mode if strict_mode: @@ -28,6 +29,7 @@ def enter(self): Mocket.enable( namespace=self.namespace, truesocket_recording_dir=self.truesocket_recording_dir, + use_hex_encoding=self.use_hex_encoding, ) if self.instance: self.check_and_call("mocketize_setup") diff --git a/tests/test_http.py b/tests/test_http.py index d516068b..a6590aea 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -55,6 +55,30 @@ def test_truesendall_with_recording(self): self.assertEqual(len(responses["httpbin.local"]["80"].keys()), 2) + def test_truesendall_with_recording_without_hex_encoding(self): + with tempfile.TemporaryDirectory() as temp_dir, Mocketizer( + truesocket_recording_dir=temp_dir, use_hex_encoding=False + ): + url = "http://httpbin.local/ip" + + urlopen(url) + requests.get(url) + resp = urlopen(url) + self.assertEqual(resp.code, 200) + resp = requests.get(url) + self.assertEqual(resp.status_code, 200) + assert "origin" in resp.json() + + dump_filename = os.path.join( + Mocket.get_truesocket_recording_dir(), + Mocket.get_namespace() + ".json", + ) + with open(dump_filename) as f: + responses = json.load(f) + + for _, value in responses["httpbin.local"]["80"].items(): + self.assertIn("HTTP/1.1 200", value["response"]) + def test_truesendall_with_gzip_recording(self): with tempfile.TemporaryDirectory() as temp_dir, Mocketizer( truesocket_recording_dir=temp_dir From 33391026a80578cf4e8ac6c3b1f53d0bc62416a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 15:17:41 +0100 Subject: [PATCH 03/11] [feature/use_hex_encoding] --- tests/test_http.py | 53 +++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tests/test_http.py b/tests/test_http.py index a6590aea..1f78bbb1 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -55,19 +55,15 @@ def test_truesendall_with_recording(self): self.assertEqual(len(responses["httpbin.local"]["80"].keys()), 2) - def test_truesendall_with_recording_without_hex_encoding(self): + def test_truesendall_with_gzip_recording(self): with tempfile.TemporaryDirectory() as temp_dir, Mocketizer( - truesocket_recording_dir=temp_dir, use_hex_encoding=False + truesocket_recording_dir=temp_dir ): - url = "http://httpbin.local/ip" + url = "http://httpbin.local/gzip" - urlopen(url) requests.get(url) - resp = urlopen(url) - self.assertEqual(resp.code, 200) resp = requests.get(url) self.assertEqual(resp.status_code, 200) - assert "origin" in resp.json() dump_filename = os.path.join( Mocket.get_truesocket_recording_dir(), @@ -76,14 +72,13 @@ def test_truesendall_with_recording_without_hex_encoding(self): with open(dump_filename) as f: responses = json.load(f) - for _, value in responses["httpbin.local"]["80"].items(): - self.assertIn("HTTP/1.1 200", value["response"]) + assert len(responses["httpbin.local"]["80"].keys()) == 1 - def test_truesendall_with_gzip_recording(self): + def test_truesendall_with_chunk_recording(self): with tempfile.TemporaryDirectory() as temp_dir, Mocketizer( truesocket_recording_dir=temp_dir ): - url = "http://httpbin.local/gzip" + url = "http://httpbin.local/range/70000?chunk_size=65536" requests.get(url) resp = requests.get(url) @@ -98,11 +93,11 @@ def test_truesendall_with_gzip_recording(self): assert len(responses["httpbin.local"]["80"].keys()) == 1 - def test_truesendall_with_chunk_recording(self): + def test_truesendall_with_recording_without_hex_encoding(self): with tempfile.TemporaryDirectory() as temp_dir, Mocketizer( - truesocket_recording_dir=temp_dir + truesocket_recording_dir=temp_dir, use_hex_encoding=False ): - url = "http://httpbin.local/range/70000?chunk_size=65536" + url = "http://httpbin.local/ip" requests.get(url) resp = requests.get(url) @@ -115,7 +110,35 @@ def test_truesendall_with_chunk_recording(self): with open(dump_filename) as f: responses = json.load(f) - assert len(responses["httpbin.local"]["80"].keys()) == 1 + for _, value in responses["httpbin.local"]["80"].items(): + self.assertIn("HTTP/1.1 200", value["response"]) + + def test_truesendall_with_gzip_recording_without_hex_encoding(self): + with tempfile.TemporaryDirectory() as temp_dir, Mocketizer( + truesocket_recording_dir=temp_dir, use_hex_encoding=False + ): + url = "http://httpbin.local/gzip" + + requests.get(url) + resp = requests.get( + url, + headers={ + "Accept-Encoding": "gzip, deflate, zstd", + }, + ) + self.assertEqual(resp.status_code, 200) + + dump_filename = os.path.join( + Mocket.get_truesocket_recording_dir(), + Mocket.get_namespace() + ".json", + ) + + with open(dump_filename) as f: + responses = json.load(f) + + for _, value in responses["httpbin.local"]["80"].items(): + self.assertIn("HTTP/1.1 200", value["response"]) + self.assertIn("gzip, deflate, zstd", value["response"]) @mocketize def test_wrongpath_truesendall(self): From 8e8f56372011b04a48c316ef6da357e2a83edfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 21:06:31 +0100 Subject: [PATCH 04/11] [feature/use_hex_encoding] --- tests/test_http.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/test_http.py b/tests/test_http.py index 1f78bbb1..63ad29e7 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -118,15 +118,14 @@ def test_truesendall_with_gzip_recording_without_hex_encoding(self): truesocket_recording_dir=temp_dir, use_hex_encoding=False ): url = "http://httpbin.local/gzip" + headers = { + "Accept-Encoding": "gzip, deflate, zstd", + } - requests.get(url) - resp = requests.get( + requests.get( url, - headers={ - "Accept-Encoding": "gzip, deflate, zstd", - }, + headers=headers, ) - self.assertEqual(resp.status_code, 200) dump_filename = os.path.join( Mocket.get_truesocket_recording_dir(), @@ -136,9 +135,15 @@ def test_truesendall_with_gzip_recording_without_hex_encoding(self): with open(dump_filename) as f: responses = json.load(f) - for _, value in responses["httpbin.local"]["80"].items(): - self.assertIn("HTTP/1.1 200", value["response"]) - self.assertIn("gzip, deflate, zstd", value["response"]) + for _, value in responses["httpbin.local"]["80"].items(): + self.assertIn("HTTP/1.1 200", value["response"]) + self.assertIn("gzip, deflate, zstd", value["response"]) + + resp = requests.get( + url, + headers=headers, + ) + self.assertEqual(resp.status_code, 200) @mocketize def test_wrongpath_truesendall(self): From 45cb3bf71fbb4aaa1e4a3f239bfcc3fc40e96fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 21:12:02 +0100 Subject: [PATCH 05/11] [feature/use_hex_encoding] --- mocket/socket.py | 15 ++++++++++----- ...test_truesendall_with_dump_from_recording.json | 14 -------------- ...test_truesendall_with_dump_from_recording.json | 14 -------------- ...test_truesendall_with_dump_from_recording.json | 14 -------------- 4 files changed, 10 insertions(+), 47 deletions(-) delete mode 100644 tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json delete mode 100644 tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json delete mode 100644 tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json diff --git a/mocket/socket.py b/mocket/socket.py index 41a718e4..2a69204e 100644 --- a/mocket/socket.py +++ b/mocket/socket.py @@ -308,8 +308,11 @@ def true_sendall(self, data, *args, **kwargs): break encoded_response += new_content - if Mocket.get_truesocket_recording_dir(): # dump the resulting dictionary to a JSON file + if Mocket.get_truesocket_recording_dir(): + # update the dictionary with request and response lines + response_dict["request"] = req + if Mocket.get_use_hex_encoding(): response_dict["response"] = hexdump(encoded_response) else: @@ -319,16 +322,18 @@ def true_sendall(self, data, *args, **kwargs): if b"content-encoding: gzip" in headers.lower(): body = gzip.decompress(body) - response_dict["response"] = (headers + b"\r\n\r\n" + body).decode( - "utf-8" - ) + response_dict["response"] = ( + headers + b"\r\n\r\n" + body + ).decode("utf-8") except UnicodeDecodeError as e: logger.warning("Mocket: Response not recorded: %s", e) with open(path, mode="w") as f: f.write( - decode_from_bytes(json.dumps(responses, indent=4, sort_keys=True)) + decode_from_bytes( + json.dumps(responses, indent=4, sort_keys=True) + ) ) # response back to .sendall() which writes it to the Mocket socket and flush the BytesIO diff --git a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json deleted file mode 100644 index 1f6534b8..00000000 --- a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 C8 8C 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" - } - } - } -} diff --git a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json deleted file mode 100644 index 898f7dfa..00000000 --- a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" - } - } - } -} diff --git a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json deleted file mode 100644 index 898f7dfa..00000000 --- a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" - } - } - } -} From 50907097eb94b49a02528ee2d304bba548d3e145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 21:14:00 +0100 Subject: [PATCH 06/11] [feature/use_hex_encoding] --- ....test_truesendall_with_dump_from_recording.json | 14 ++++++++++++++ ....test_truesendall_with_dump_from_recording.json | 14 ++++++++++++++ ....test_truesendall_with_dump_from_recording.json | 14 ++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json create mode 100644 tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json create mode 100644 tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json diff --git a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json new file mode 100644 index 00000000..704f6840 --- /dev/null +++ b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -0,0 +1,14 @@ +{ + "httpbin.local": { + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 D8 42 3E 67 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 94 6A BB 31 BA 6B 4C D5 03 E8 01 10 C6 96 14 81 00 BA 68 D3 BB 0B 34 21 2E BF 37 6F FE 96 02 21 3C CC C2 18 E0 F8 84 BC FD 40 85 22 1B 81 72 B0 2E B0 25 C4 00 3A C6 C0 F8 90 71 B9 2B 71 92 32 25 BD 62 9A 0B 35 C4 72 9C 56 21 0E 2F 49 7D 18 36 3B CF B3 7E D6 4A 01 F3 42 AB 68 4E 00 86 50 29 BE 90 85 9B 76 69 C7 E8 BD 79 0A 55 4B CD A8 CC D5 87 03 4B BA 01 54 72 2E 74 02 F2 87 82 B3 6E C7 BF C1 8F 3A FE 83 AF FD 7D EB C6 DA 8A 41 A4 B5 CD A1 AD 9B 63 BD AF 5B 5C AC C5 0F 4E 03 DB 8A 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 31 39 2E 30 2E 32 22 0A 7D 0A" + } + } + } +} \ No newline at end of file diff --git a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json new file mode 100644 index 00000000..704f6840 --- /dev/null +++ b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -0,0 +1,14 @@ +{ + "httpbin.local": { + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 D8 42 3E 67 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 94 6A BB 31 BA 6B 4C D5 03 E8 01 10 C6 96 14 81 00 BA 68 D3 BB 0B 34 21 2E BF 37 6F FE 96 02 21 3C CC C2 18 E0 F8 84 BC FD 40 85 22 1B 81 72 B0 2E B0 25 C4 00 3A C6 C0 F8 90 71 B9 2B 71 92 32 25 BD 62 9A 0B 35 C4 72 9C 56 21 0E 2F 49 7D 18 36 3B CF B3 7E D6 4A 01 F3 42 AB 68 4E 00 86 50 29 BE 90 85 9B 76 69 C7 E8 BD 79 0A 55 4B CD A8 CC D5 87 03 4B BA 01 54 72 2E 74 02 F2 87 82 B3 6E C7 BF C1 8F 3A FE 83 AF FD 7D EB C6 DA 8A 41 A4 B5 CD A1 AD 9B 63 BD AF 5B 5C AC C5 0F 4E 03 DB 8A 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 31 39 2E 30 2E 32 22 0A 7D 0A" + } + } + } +} \ No newline at end of file diff --git a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json new file mode 100644 index 00000000..de7eeb5c --- /dev/null +++ b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -0,0 +1,14 @@ +{ + "httpbin.local": { + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 33 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 D9 42 3E 67 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 94 6A BB 31 BA 6B 4C D5 03 E8 01 10 C6 96 14 81 00 BA 68 D3 BB 0B 34 21 2E BF 37 6F FE 96 02 21 3C CC C2 18 E0 F8 84 BC FD 40 85 22 1B 81 72 B0 2E B0 25 C4 00 3A C6 C0 F8 90 71 B9 2B 71 92 32 25 BD 62 9A 0B 35 C4 72 9C 56 21 0E 2F 49 7D 18 36 3B CF B3 7E D6 4A 01 F3 42 AB 68 4E 00 86 50 29 BE 90 85 9B 76 69 C7 E8 BD 79 0A 55 4B CD A8 CC D5 87 03 4B BA 01 54 72 2E 74 02 F2 87 82 B3 6E C7 BF C1 8F 3A FE 83 AF FD 7D EB C6 DA 8A 41 A4 B5 CD A1 AD 9B 63 BD AF 5B 5C AC C5 0F 4E 03 DB 8A 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 31 39 2E 30 2E 32 22 0A 7D 0A" + } + } + } +} \ No newline at end of file From 775583de0677829e32ab9dedccd4088ef568ca98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Wed, 20 Nov 2024 21:15:33 +0100 Subject: [PATCH 07/11] [feature/use_hex_encoding] --- ..._truesendall_with_dump_from_recording.json | 20 +++++++++---------- ..._truesendall_with_dump_from_recording.json | 20 +++++++++---------- ..._truesendall_with_dump_from_recording.json | 20 +++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json index 704f6840..2dbf9f6c 100644 --- a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -1,14 +1,14 @@ { "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 D8 42 3E 67 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 94 6A BB 31 BA 6B 4C D5 03 E8 01 10 C6 96 14 81 00 BA 68 D3 BB 0B 34 21 2E BF 37 6F FE 96 02 21 3C CC C2 18 E0 F8 84 BC FD 40 85 22 1B 81 72 B0 2E B0 25 C4 00 3A C6 C0 F8 90 71 B9 2B 71 92 32 25 BD 62 9A 0B 35 C4 72 9C 56 21 0E 2F 49 7D 18 36 3B CF B3 7E D6 4A 01 F3 42 AB 68 4E 00 86 50 29 BE 90 85 9B 76 69 C7 E8 BD 79 0A 55 4B CD A8 CC D5 87 03 4B BA 01 54 72 2E 74 02 F2 87 82 B3 6E C7 BF C1 8F 3A FE 83 AF FD 7D EB C6 DA 8A 41 A4 B5 CD A1 AD 9B 63 BD AF 5B 5C AC C5 0F 4E 03 DB 8A 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 31 39 2E 30 2E 32 22 0A 7D 0A" - } + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 C8 8C 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" } + } } -} \ No newline at end of file + } \ No newline at end of file diff --git a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json index 704f6840..6ba3d192 100644 --- a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -1,14 +1,14 @@ { "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 D8 42 3E 67 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 94 6A BB 31 BA 6B 4C D5 03 E8 01 10 C6 96 14 81 00 BA 68 D3 BB 0B 34 21 2E BF 37 6F FE 96 02 21 3C CC C2 18 E0 F8 84 BC FD 40 85 22 1B 81 72 B0 2E B0 25 C4 00 3A C6 C0 F8 90 71 B9 2B 71 92 32 25 BD 62 9A 0B 35 C4 72 9C 56 21 0E 2F 49 7D 18 36 3B CF B3 7E D6 4A 01 F3 42 AB 68 4E 00 86 50 29 BE 90 85 9B 76 69 C7 E8 BD 79 0A 55 4B CD A8 CC D5 87 03 4B BA 01 54 72 2E 74 02 F2 87 82 B3 6E C7 BF C1 8F 3A FE 83 AF FD 7D EB C6 DA 8A 41 A4 B5 CD A1 AD 9B 63 BD AF 5B 5C AC C5 0F 4E 03 DB 8A 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 31 39 2E 30 2E 32 22 0A 7D 0A" - } + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" } + } } -} \ No newline at end of file + } \ No newline at end of file diff --git a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json index de7eeb5c..6ba3d192 100644 --- a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -1,14 +1,14 @@ { "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 33 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 D9 42 3E 67 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 94 6A BB 31 BA 6B 4C D5 03 E8 01 10 C6 96 14 81 00 BA 68 D3 BB 0B 34 21 2E BF 37 6F FE 96 02 21 3C CC C2 18 E0 F8 84 BC FD 40 85 22 1B 81 72 B0 2E B0 25 C4 00 3A C6 C0 F8 90 71 B9 2B 71 92 32 25 BD 62 9A 0B 35 C4 72 9C 56 21 0E 2F 49 7D 18 36 3B CF B3 7E D6 4A 01 F3 42 AB 68 4E 00 86 50 29 BE 90 85 9B 76 69 C7 E8 BD 79 0A 55 4B CD A8 CC D5 87 03 4B BA 01 54 72 2E 74 02 F2 87 82 B3 6E C7 BF C1 8F 3A FE 83 AF FD 7D EB C6 DA 8A 41 A4 B5 CD A1 AD 9B 63 BD AF 5B 5C AC C5 0F 4E 03 DB 8A 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 57 65 64 2C 20 32 30 20 4E 6F 76 20 32 30 32 34 20 32 30 3A 31 33 3A 31 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 31 39 2E 30 2E 32 22 0A 7D 0A" - } + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" } + } } -} \ No newline at end of file + } \ No newline at end of file From 45535141b4f81973c342e9b9252505d238aeaef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Thu, 21 Nov 2024 13:56:39 +0100 Subject: [PATCH 08/11] [feature/use_hex_encoding] --- ..._truesendall_with_dump_from_recording.json | 22 +++++++++---------- ..._truesendall_with_dump_from_recording.json | 22 +++++++++---------- ..._truesendall_with_dump_from_recording.json | 22 +++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json index 2dbf9f6c..1f6534b8 100644 --- a/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ b/tests/tests.test_http.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -1,14 +1,14 @@ { - "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 C8 8C 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" - } + "httpbin.local": { + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 C8 8C 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 35 3A 35 32 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" } } - } \ No newline at end of file + } +} diff --git a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json index 6ba3d192..898f7dfa 100644 --- a/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ b/tests/tests.test_http_gevent.GeventHttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -1,14 +1,14 @@ { - "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" - } + "httpbin.local": { + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" } } - } \ No newline at end of file + } +} diff --git a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json index 6ba3d192..898f7dfa 100644 --- a/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json +++ b/tests/tests.test_http_with_xxhash.HttpEntryTestCase.test_truesendall_with_dump_from_recording.json @@ -1,14 +1,14 @@ { - "httpbin.local": { - "80": { - "0b717b72090e760066708581e9024a2e": { - "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" - }, - "e2843e7232537a417f14a0cdaf97730e": { - "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", - "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" - } + "httpbin.local": { + "80": { + "0b717b72090e760066708581e9024a2e": { + "request": "GET /gzip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 31 38 39 0D 0A 63 6F 6E 74 65 6E 74 2D 65 6E 63 6F 64 69 6E 67 3A 20 67 7A 69 70 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 1F 8B 08 00 99 8D 88 65 02 FF 4D 8F 4D 0E C2 20 10 46 F7 3D 05 61 D9 B4 A8 6C 4C DC 35 A6 EA 01 F4 00 08 23 25 45 20 ED E8 A2 4D EF 2E D0 A4 71 F9 BD 79 F3 37 17 84 50 3D 99 10 40 D1 13 C1 E1 03 15 49 AC 03 A1 60 18 23 9B 63 8C A0 91 12 02 C6 4C CB 5D 49 B3 B4 D1 BA 75 D2 2B E3 74 2A A7 69 15 51 F0 B2 02 E3 B0 69 44 B5 E9 67 EF 1C 48 34 DE 25 B3 07 08 B5 B0 E6 0B 9B 70 F3 63 DE D1 21 86 A7 71 CC 7A 29 EC 56 7D 8C 30 D4 8D 06 97 9D 8B E8 A1 FE 43 D1 59 D6 E3 DF 80 9D 4F FF D0 6B 7B 5F BB A9 1F 8C 36 79 ED E1 C8 19 E7 6C CF 38 2D 96 E2 07 90 26 B9 E3 02 01 00 00" + }, + "e2843e7232537a417f14a0cdaf97730e": { + "request": "GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nuser-agent: Fake-User-Agent\r\nAccept-Encoding: gzip, deflate, zstd\r\nAccept: */*\r\nConnection: keep-alive\r\n\r\n", + "response": "48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D 0A 58 2D 50 6F 77 65 72 65 64 2D 42 79 3A 20 45 78 70 72 65 73 73 0D 0A 73 65 72 76 65 72 3A 20 67 75 6E 69 63 6F 72 6E 2F 31 39 2E 39 2E 30 0D 0A 64 61 74 65 3A 20 53 75 6E 2C 20 32 34 20 44 65 63 20 32 30 32 33 20 31 39 3A 35 39 3A 32 31 20 47 4D 54 0D 0A 63 6F 6E 6E 65 63 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 0D 0A 63 6F 6E 74 65 6E 74 2D 74 79 70 65 3A 20 61 70 70 6C 69 63 61 74 69 6F 6E 2F 6A 73 6F 6E 0D 0A 63 6F 6E 74 65 6E 74 2D 6C 65 6E 67 74 68 3A 20 32 39 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 6F 72 69 67 69 6E 3A 20 2A 0D 0A 61 63 63 65 73 73 2D 63 6F 6E 74 72 6F 6C 2D 61 6C 6C 6F 77 2D 63 72 65 64 65 6E 74 69 61 6C 73 3A 20 74 72 75 65 0D 0A 0D 0A 7B 0A 20 20 22 6F 72 69 67 69 6E 22 3A 20 22 31 37 32 2E 32 32 2E 30 2E 32 22 0A 7D 0A" } } - } \ No newline at end of file + } +} From a8ca787f2c76c4a6041ea36e4b4c463160a08514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Fri, 22 Nov 2024 10:26:55 +0100 Subject: [PATCH 09/11] [feature/use_hex_encoding] --- mocket/socket.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/mocket/socket.py b/mocket/socket.py index 2a69204e..d711fd72 100644 --- a/mocket/socket.py +++ b/mocket/socket.py @@ -12,7 +12,7 @@ from datetime import datetime, timedelta from json.decoder import JSONDecodeError -from mocket.compat import decode_from_bytes, encode_to_bytes +from mocket.compat import decode_from_bytes, encode_to_bytes, ENCODING from mocket.inject import ( true_gethostbyname, true_socket, @@ -23,7 +23,6 @@ from mocket.mode import MocketMode from mocket.utils import hexdump, hexload - logger = logging.getLogger(__name__) xxh32 = None try: @@ -275,8 +274,8 @@ def true_sendall(self, data, *args, **kwargs): else: headers, body = response.split("\r\n\r\n", 1) - headers_bytes = headers.encode("utf-8") - body_bytes = body.encode("utf-8") + headers_bytes = headers.encode(ENCODING) + body_bytes = body.encode(ENCODING) if "content-encoding: gzip" in headers.lower(): body_bytes = gzip.compress(body_bytes) @@ -316,18 +315,14 @@ def true_sendall(self, data, *args, **kwargs): if Mocket.get_use_hex_encoding(): response_dict["response"] = hexdump(encoded_response) else: - try: - headers, body = encoded_response.split(b"\r\n\r\n", 1) - - if b"content-encoding: gzip" in headers.lower(): - body = gzip.decompress(body) + headers, body = encoded_response.split(b"\r\n\r\n", 1) - response_dict["response"] = ( - headers + b"\r\n\r\n" + body - ).decode("utf-8") + if b"content-encoding: gzip" in headers.lower(): + body = gzip.decompress(body) - except UnicodeDecodeError as e: - logger.warning("Mocket: Response not recorded: %s", e) + response_dict["response"] = (headers + b"\r\n\r\n" + body).decode( + ENCODING + ) with open(path, mode="w") as f: f.write( From 82d27c2bff110165b6f49763d29481ee9e5d4253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Fri, 22 Nov 2024 11:00:19 +0100 Subject: [PATCH 10/11] [feature/use_hex_encoding] --- mocket/socket.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mocket/socket.py b/mocket/socket.py index d711fd72..a313b5ec 100644 --- a/mocket/socket.py +++ b/mocket/socket.py @@ -3,7 +3,6 @@ import gzip import hashlib import json -import logging import os import re import select @@ -23,7 +22,6 @@ from mocket.mode import MocketMode from mocket.utils import hexdump, hexload -logger = logging.getLogger(__name__) xxh32 = None try: from xxhash import xxh32 From f82eb7fb130096744c490f1058d298c6fa011aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20W=C3=B3jciak?= Date: Fri, 22 Nov 2024 11:01:01 +0100 Subject: [PATCH 11/11] [feature/use_hex_encoding] --- mocket/socket.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mocket/socket.py b/mocket/socket.py index a313b5ec..9a97fbeb 100644 --- a/mocket/socket.py +++ b/mocket/socket.py @@ -4,7 +4,6 @@ import hashlib import json import os -import re import select import socket import ssl