@@ -213,7 +213,7 @@ def _decode_request_body(self, app: EventHandlerInstance) -> bytes:
213213 def _extract_boundary_bytes (self , content_type : str ) -> bytes :
214214 """Extract and return the boundary bytes from the content type header."""
215215 boundary_match = re .search (r"boundary=([^;,\s]+)" , content_type )
216-
216+
217217 if not boundary_match :
218218 # Handle WebKit browsers that may use different boundary formats
219219 webkit_match = re .search (r"WebKitFormBoundary([a-zA-Z0-9]+)" , content_type )
@@ -223,13 +223,13 @@ def _extract_boundary_bytes(self, content_type: str) -> bytes:
223223 raise ValueError ("No boundary found in multipart content-type" )
224224 else :
225225 boundary = boundary_match .group (1 ).strip ('"' )
226-
226+
227227 return ("--" + boundary ).encode ("utf-8" )
228228
229229 def _parse_multipart_sections (self , decoded_bytes : bytes , boundary_bytes : bytes ) -> dict [str , Any ]:
230230 """Parse individual multipart sections from the decoded body."""
231231 parsed_data : dict [str , Any ] = {}
232-
232+
233233 if not decoded_bytes :
234234 return parsed_data
235235
@@ -248,7 +248,7 @@ def _parse_multipart_sections(self, decoded_bytes: bytes, boundary_bytes: bytes)
248248 def _parse_multipart_section (self , section : bytes ) -> tuple [str | None , bytes | str ]:
249249 """Parse a single multipart section to extract field name and content."""
250250 headers_part , content = self ._split_section_headers_and_content (section )
251-
251+
252252 if headers_part is None :
253253 return None , b""
254254
@@ -258,7 +258,7 @@ def _parse_multipart_section(self, section: bytes) -> tuple[str | None, bytes |
258258 return None , b""
259259
260260 field_name = name_match .group (1 )
261-
261+
262262 # Check if it's a file field and process accordingly
263263 if "filename=" in headers_part :
264264 # It's a file - store as bytes
@@ -274,9 +274,9 @@ def _split_section_headers_and_content(self, section: bytes) -> tuple[str | None
274274 header_end = section .find (b"\n \n " )
275275 if header_end == - 1 :
276276 return None , b""
277- content = section [header_end + 2 :].strip ()
277+ content = section [header_end + 2 :].strip ()
278278 else :
279- content = section [header_end + 4 :].strip ()
279+ content = section [header_end + 4 :].strip ()
280280
281281 headers_part = section [:header_end ].decode ("utf-8" , errors = "ignore" )
282282 return headers_part , content
0 commit comments