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

Unable to read big json file from Request.Body #3235

Closed
anfomin opened this issue Sep 30, 2015 · 8 comments
Closed

Unable to read big json file from Request.Body #3235

anfomin opened this issue Sep 30, 2015 · 8 comments

Comments

@anfomin
Copy link

anfomin commented Sep 30, 2015

I'm trying to read big JSON file (UTF8) from Request.Body stream:

string content;
using (var sr = new StreamReader(Request.Body, Encoding.Default))
    content = sr.ReadToEnd();

At the beginning it's ok, but content variable contains invalid character sequence after some offset.

Sample repo: https://github.com/anfomin/DNX-MVC-bigfile. There is file sample.json. Just run dnx kestrel and make:

POST http://localhost:5000

with body = sample.json file.

You will find mismatches since line 84.

Source:
2015-09-30 19 58 00

Result:
2015-09-30 19 58 18

I've tried latest DNX 1.0.0-beta8-15736 from https://www.myget.org/F/aspnetvnext/api/v2 and 1.0.0-rc1-15775 from https://www.myget.org/F/aspnetcidev/api/v2.

@Eilon
Copy link
Member

Eilon commented Sep 30, 2015

@kichalla can you take a look?

@kichalla
Copy link
Member

@anfomin I suppose you are running on Mono on Linux? was curious if Encoding.Default was doing something here but looks like some content is entirely missing based on your snapshot above...just to isolate the issue, can you try saving the read content to a file and see if the contents are any different? also does this issue repro consistently for you?

@anfomin
Copy link
Author

anfomin commented Sep 30, 2015

@kichalla I tried this sample both on Windows and Mac, result is the same.

Also I tried to save Request.Body to a text file via File.CreateText("..."). Result file contains the same corruptions. You can remove Encoding.Default, the result does not change.

The problem is Request.Body because when I change input stream to File.Open(...) then output is correct.

@kichalla
Copy link
Member

@anfomin you are right, I was able to repro it on a Windows machine now..investigating...

left -> actual file content
right -> content read from request body and saved to a file
image

@Eilon Eilon added this to the 6.0.0-rc1 milestone Sep 30, 2015
@Eilon
Copy link
Member

Eilon commented Sep 30, 2015

Weird... putting this on RC. Please enlist @halter73 @lodejard @Tratcher @moozzyk if needed because this might even be a Kestrel issue.

@kichalla
Copy link
Member

Yeah, this seems like a Kestrel issue as I cannot repro it with weblistener

@Tratcher
Copy link
Member

This issue was moved to aspnet/KestrelHttpServer#234

@lodejard
Copy link
Contributor

Certainly could be - that part of the code was updated heavily recently

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

No branches or pull requests

5 participants