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

InvalidDataException: Line length limit 100 exceeded #3057

Closed
thomasd3 opened this issue Oct 25, 2018 · 1 comment
Closed

InvalidDataException: Line length limit 100 exceeded #3057

thomasd3 opened this issue Oct 25, 2018 · 1 comment

Comments

@thomasd3
Copy link

thomasd3 commented Oct 25, 2018

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

@Tratcher
Copy link
Member

This issue was moved to dotnet/aspnetcore#3724

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants