Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidDataException: Line length limit 100 exceeded #3724

Closed
Tratcher opened this issue Oct 25, 2018 · 2 comments
Closed

InvalidDataException: Line length limit 100 exceeded #3724

Tratcher opened this issue Oct 25, 2018 · 2 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@Tratcher
Copy link
Member

From @thomasd3 on October 25, 2018 20:11

When uploading data files with RestSharp to a .Net Core 2.1 REST interface, I get this error on some files:

System.IO.InvalidDataException: Line length limit 100 exceeded.
   at Microsoft.AspNetCore.WebUtilities.BufferedReadStream.ReadLineAsync(Int32 lengthLimit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.MultipartReader.ReadNextSectionAsync(CancellationToken cancellationToken)

When I do the same operation with Insomnia, I do not get any error, only with RestSharp.

I have read here https://stackoverflow.com/questions/44642701/microsoft-aspnetcore-webutilities-line-length-limit-100-exceeded that there is a problem with the line ending formats, but this is the only article about it.

The controller signature is very simple:

[HttpPost, DisableRequestSizeLimit]
public async Task<IActionResult> AddPictureAsync(
	IFormFile Picture,
	IFormFile Thumbnail,
	string Title)
{

and the code to send is:

var Request = new RestRequest("picture", Method.POST) { AlwaysMultipartFormData = true };
Request.AddHeader("SessionId", SessionId);
Request.AddFile("Picture", PhotoData.ToArray(), Photo.PhotoUrl);
Request.AddFile("Thumbnail", ThumbnailData, Photo.PhotoUrl.Replace(".jpg", "-t.jpg"));
Request.AddParameter("Title", Photo.Title ?? string.Empty, ParameterType.GetOrPost);

If I understand the error, it means that the data lines are longer than they should. But is there a way to inspect what is coming in? My controller doesn't even get executed, the error happens before

Copied from original issue: aspnet/KestrelHttpServer#3057

@Tratcher
Copy link
Member Author

This error is not related to the request size limits, but rather the form size limits. And as you say it's likely more of a formatting issue.

Fiddler or Wireshark are good tools for capturing what bytes were written to the wire. Kestrel also has a feature called connection logging for viewing the raw bytes.

@analogrelay
Copy link
Contributor

Closing this as we haven't heard from you. Please feel free to comment if you're able to get the information we're looking for and we can reopen the issue if we're able to identify the problem.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

4 participants