Skip to content

v0.4.0

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Nov 07:25
· 4 commits to main since this release
77e0afa
  • Requires base-scheduler 0.5, base-pool 0.5 and base-endpoint 0.3. This is a breaking change: scheduler, pool and endpoint types such as Cancellation and ReadableStream appear in the public API, so callers must use the same versions. The HTTP crates read sockets only through read_into and try_read_into, whose readiness contract scheduler 0.5 leaves unchanged, so HTTP/1 input and the client's idle-connection check are unaffected by its wider readiness rule. The Tokio adapter's read_into now clears readiness after a short read on Linux and Android, which that contract already allowed. Scheduler 0.5 removes the Direct backend; run on base-scheduler-native or base-scheduler-tokio instead.
  • Add base-http-content, which reads a request's body into a structure declared with base-web-content's #[derive(Content)]. read_content chooses the format from the request's Content-Type, refuses a request whose Content-Length exceeds the largest body the declaration could accept with 413 before reading any of it, reads the body frame by frame as it arrives, and streams uploads to an UploadStore. When the content is refused, or reading or storing fails, it aborts the upload in progress, removes every upload it stored, and closes the body. ReadError::status gives one status for each failure: 413, the content error's own 400, 413 or 415, 422 for violations, 400 for a malformed Content-Type or a body that fails, and 500 for a store that fails. FileStore saves each upload to a new file at a path the application chooses from the field's declared path, never from the submitted filename: it creates the file exclusively, refusing anything at the path including a symbolic link, with permissions 0600 on Unix by default, removes it when the upload is aborted, as read_content does whenever writing it fails, and does its file I/O on the scheduler's blocking threads. NoUploads reads declarations without uploads. Cleanup is asynchronous, so a read whose future is dropped, as base-http-server drops a handler's future at shutdown, leaves what it stored in place. The package depends on base-http, base-web-content, base-web-media-type and the scheduler interface, not on a server or protocol codec.
  • base-http adds Status::UNPROCESSABLE_CONTENT (422).
  • base-http's license.md and the headers of its messages, fields and bodies, which are ported from protocol-http, again credit the authors and years of the files they derive from, restoring the copyright lines that the first release's license update replaced.