Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

[MultipartReaderStream] Misleading exception message #736

Closed
Eilon opened this issue Nov 18, 2016 · 3 comments
Closed

[MultipartReaderStream] Misleading exception message #736

Eilon opened this issue Nov 18, 2016 · 3 comments
Assignees
Labels

Comments

@Eilon
Copy link
Member

Eilon commented Nov 18, 2016

From @mabakay on November 16, 2016 22:53

When multipart/form-data request is malformed for instance (missing double dash at boundary start):

9051914041544843365972754266
Content-Disposition: form-data; name="text"

text default
--9051914041544843365972754266--

and request body is greater than default limit for HeadersLengthLimit (which is 16KB now), user get exception message of "Multipart body length limit 16384 exceeded."

MultipartReaderStream.cs #166

Copied from original issue: aspnet/Mvc#5534

@muratg
Copy link

muratg commented Nov 21, 2016

Assigning to @Tratcher for investigation.

@muratg muratg modified the milestones: 1.2.0, 2.0.0 Jan 12, 2017
@muratg muratg modified the milestones: 2.0.0, 2.0.0-preview1 Apr 11, 2017
@muratg muratg modified the milestones: 2.1.0, 2.0.0 Jun 27, 2017
@Tratcher
Copy link
Member

The confusion here is that multipart forms don't start with the first boundary, there can be an arbitrary amount of data prior to the first boundary.

Hello world, how are you? This is preamble data
--9051914041544843365972754266
Content-Disposition: form-data; name="text"

text default
--9051914041544843365972754266--

Because the boundary is not correctly formatted in your example, that data is all parsed as part of the initial 'body' and so the body limit applies. Note that the limits can't currently be configured for this initial section.

// This stream will drain any preamble data and remove the first boundary marker.
// TODO: HeadersLengthLimit can't be modified until after the constructor.
_currentStream = new MultipartReaderStream(_stream, _boundary) { LengthLimit = HeadersLengthLimit };

@muratg muratg modified the milestones: 2.1.0, 2.1.0-preview1 Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants