HTTP client will upload Chunks of arbitrary size, which will be rejected by Akka
- Dominant language
- Scala
- Stars
- 1.4k
- Forks
- 584
- Avg merge
- 14h 33m
- Merged PRs (30d)
- 24
Description
**Issue by [RichardBradley](https://github.com/RichardBradley)**
_Monday Mar 23, 2015 at 12:28 GMT_
_Originally opened as https://github.com/akka/akka/issues/17063_
---
The [multipartMarshaller](https://github.com/akka/akka/blob/231a2a0d12c5a96b8b6974ff00839d65f0f7fa6a/akka-http/src/main/scala/akka/http/marshalling/MultipartMarshallers.scala#L41) in HTTP 1.0-M4 will convert a `Multipart` object into a `Chunked` HTTP request, but it does not take any notice of the size of the chunks generated.
Akka's default `max-chunk-size` is 1M, so it is easy to generate requests via this route which will be rejected by an Akka HTTP server (especially as any nested MIME parts can't be used directly (Chunked v.s. IndefiniteLength), so devs are tempted to call "toStrict" on them).
I think that the Marshaller should automatically re-chunk the stream to respect `max-chunk-size`.
(Or perhaps the Akka HTTP client should re-chunk streams, to solve this for all code paths?)
Maybe the underlying issue here is that the `multipartMarshaller` produces Chunked entities, but doesn't accept Chunked entities when making nested MIME messages. I think there should be an implicit conversion from Chunked to IndefiniteLength, which would make creating streamed nested MIME messages much easier (or perhaps IndefiniteLength should be removed and Chunked used directly instead?)
Contributor guide
Research direction
Start with akka-http/src/main/scala/akka/http/marshalling/MultipartMarshallers.scala, especially multipartMarshaller and its handling of generated chunks. Reproduce a multipart request with chunks larger than Akka's 1M max-chunk-size and determine the expected behavior for nested MIME entities; done should be defined by requests that are accepted without exceeding the configured limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100