For intrepid commit message readers:
The choice to add allows for the inlined format args lint instead of actually
inlining them is not very clear because our actual real world MSRV is not clear.
We currently claim 1.60 is our MSRV but this is mainly due to dependencies. I'm
fairly sure that we could support < 1.58 if those deps are outdated in a users
lockfile. We'll remove these allows again at some point soon.
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
Co-authored-by: Rob Ede <robjtede@icloud.com>
* Fix Multipart consuming payload before header checks
What
--
Split up logic in the constructor into two functions:
- **from_boundary:** build Multipart from boundary and stream
- **from_error:** build Multipart for MultipartError
Also we make the `boundary`, `from_boundary`, `from_error` methods public within the crate so that we can use them in the extractor.
The extractor is then able to perform header checks and only consume the
payload if the checks pass.
* Add tests
* Add payload consumption test
Co-authored-by: Rob Ede <robjtede@icloud.com>
* actix-multipart: Fix multipart boundary reading
If we're not ready to read the first line after the multipart field
(which should be a "\r\n" line) then return Pending instead of Ready(None)
so that we will get called again to read that line.
Without this I was getting MultipartError::Boundary from read_boundary()
because it got the "\r\n" line instead of the boundary.
Also tweaks the test_stream test to test partial reads.
This is a forward port of #1189 from 1.0
* actix-multipart: Update changes for boundary fix
* Replace UnsafeCell in DateServiceInner with Cell
The previous API was extremely dangerous - calling `get_ref()`
followed by `reset()` would trigger instant UB, without requiring
any `unsafe` blocks in the caller.
By making DateInner `Copy`, we can use a normal `Cell` instead
of an `UnsafeCell`. This makes it impossible to cause UB (or even panic)
with the API.
* Split unsafe block HttpServiceHandlerResponse
Also add explanation of the safety of the usage of `unsafe`
* Replace UnsafeCell with RefCell in PayloadRef
This ensures that a mistake in the usage of 'get_mut' will cause
a panic, not undefined behavior.