| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2026-02-15 | 2.7 kB | |
| v2.6.0 source code.tar.gz | 2026-02-15 | 2.1 MB | |
| v2.6.0 source code.zip | 2026-02-15 | 2.2 MB | |
| Totals: 3 Items | 4.2 MB | 0 | |
- Add support for handling
FromText,FromFilesin OpenAPI Documentation (#546). - Significantly improve support for
multipart/form-dataforms with memory-efficient streaming and file handling: - Add
Request.multipart_stream()method for true streaming parsing of multipart data without buffering entire request body in memory, ideal for handling large file uploads and large text fields. - Refactor
Request.form()andRequest.multipart()to useSpooledTemporaryFilefor memory-efficient file handling: small files (<1MB) are kept in memory, larger files automatically spill to temporary disk files. - Add
Request.dispose()method to properly clean upSpooledTemporaryFileresources and prevent resource leaks when handling file uploads. - Add
FileBufferclass wrappingSpooledTemporaryFileto provide a clean API for uploaded files withread(),seek(),close(), andsave_to()methods. - Add
FormPart.stream()async generator method to stream part data in chunks. - Add
save_to()method toFormPart,FileBuffer, andStreamedFormPartfor saving uploaded data to disk with automatic security validation viaensure_in_cwd()to prevent directory traversal attacks. - Add
FormPart.field()class method as a convenience for creating form parts from string values without manual encoding (acceptsname,value, optionalcontent_typeandcharset). - Add
FormPart.from_file()class method as a convenience for creating file upload parts that automatically opens files, detects MIME types from file extensions, and handles both file paths and pre-opened file handles. FormPartinstances provide better memory management and a cleaner API.- The framework automatically calls
Request.dispose()at the end of each request-response cycle to clean up file resources. - Fix #501; accept to overwrite default headers when using
TestClient, contributed by @ticapix. - Modify the
MultiPartFormDatato inheritStreamedContentand remove the immediate call towrite_multipart_form_data()which loaded everything into memory.
[!NOTE] Support for efficient handling of
multipart/form-datawas previously neglected as BlackSheep focused primarily on JSON-based Web APIs, Web Apps serving HTML and static files, and raw request body streaming for large uploads. This release improves support for this format, adding support for memory-efficient handling ofmultipart/form-data, both when parsing on the server-side and when writing payloads for the BlackSheep HTTP Client, through theMultiPartFormDatacontent class.