From e43e0ed5d5de754c49d3442e99b26f30c0d86c3d Mon Sep 17 00:00:00 2001 From: Sky O Date: Fri, 29 Mar 2024 16:50:18 +0000 Subject: [PATCH] Add repr --- moto/moto_proxy/utils.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/moto/moto_proxy/utils.py b/moto/moto_proxy/utils.py index bd1646506..23e98e27c 100644 --- a/moto/moto_proxy/utils.py +++ b/moto/moto_proxy/utils.py @@ -6,10 +6,16 @@ class Part: headers = [] data : bytes + def __repr__(self): + return f"Part(headers={repr(self.headers)}, data={self.data})" + class Header: name : bytes value : bytes + def __repr__(self): + return f"{self.name}:{self.value}" + def get_body_from_form_data( body: bytes, boundary: str ) -> Tuple[Optional[bytes], Dict[str, str]]: @@ -80,16 +86,21 @@ def get_body_from_form_data( print("YO PARTS", parts) data = None headers: Dict[str, str] = {} - for prt in parser.parts(): - if prt.name == "upload_file": - headers["key"] = prt.name - data = prt.file.read() - else: - val = prt.file.read() - if prt.name == "file": - data = val - else: - headers[prt.name] = val.decode("utf-8") + + # for part in parts: + # for header in part.headers: + # if header.key + + # for prt in parser.parts(): + # if prt.name == "upload_file": + # headers["key"] = prt.name + # data = prt.file.read() + # else: + # val = prt.file.read() + # if prt.name == "file": + # data = val + # else: + # headers[prt.name] = val.decode("utf-8") return data, headers # form_data file