@@ -213,7 +213,7 @@ def _decode_request_body(self, app: EventHandlerInstance) -> bytes:
213
213
def _extract_boundary_bytes (self , content_type : str ) -> bytes :
214
214
"""Extract and return the boundary bytes from the content type header."""
215
215
boundary_match = re .search (r"boundary=([^;,\s]+)" , content_type )
216
-
216
+
217
217
if not boundary_match :
218
218
# Handle WebKit browsers that may use different boundary formats
219
219
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:
223
223
raise ValueError ("No boundary found in multipart content-type" )
224
224
else :
225
225
boundary = boundary_match .group (1 ).strip ('"' )
226
-
226
+
227
227
return ("--" + boundary ).encode ("utf-8" )
228
228
229
229
def _parse_multipart_sections (self , decoded_bytes : bytes , boundary_bytes : bytes ) -> dict [str , Any ]:
230
230
"""Parse individual multipart sections from the decoded body."""
231
231
parsed_data : dict [str , Any ] = {}
232
-
232
+
233
233
if not decoded_bytes :
234
234
return parsed_data
235
235
@@ -248,7 +248,7 @@ def _parse_multipart_sections(self, decoded_bytes: bytes, boundary_bytes: bytes)
248
248
def _parse_multipart_section (self , section : bytes ) -> tuple [str | None , bytes | str ]:
249
249
"""Parse a single multipart section to extract field name and content."""
250
250
headers_part , content = self ._split_section_headers_and_content (section )
251
-
251
+
252
252
if headers_part is None :
253
253
return None , b""
254
254
@@ -258,7 +258,7 @@ def _parse_multipart_section(self, section: bytes) -> tuple[str | None, bytes |
258
258
return None , b""
259
259
260
260
field_name = name_match .group (1 )
261
-
261
+
262
262
# Check if it's a file field and process accordingly
263
263
if "filename=" in headers_part :
264
264
# It's a file - store as bytes
@@ -274,9 +274,9 @@ def _split_section_headers_and_content(self, section: bytes) -> tuple[str | None
274
274
header_end = section .find (b"\n \n " )
275
275
if header_end == - 1 :
276
276
return None , b""
277
- content = section [header_end + 2 :].strip ()
277
+ content = section [header_end + 2 :].strip ()
278
278
else :
279
- content = section [header_end + 4 :].strip ()
279
+ content = section [header_end + 4 :].strip ()
280
280
281
281
headers_part = section [:header_end ].decode ("utf-8" , errors = "ignore" )
282
282
return headers_part , content
0 commit comments