amphp/http-server-form-parser

While using https, the stream ended with only ~99.8% of the current length.

Closed this issue · 14 comments

I'm using http-server and http-server-form-parser to manage uploads of files. I was testing with files of about 350 MB, but while you can upload files of this size normally with http, with https, the stream is incomplete so my script waits infinitely for it to complete and the browser throws ERR_EMPTY_RESPONSE as a result. With the upload I'm sending the file_size by javascript, if I don't send it, the upload goes right (this approach works fine with http).

So you're saying that the stream ends before the file size sent by Javascript? I question if that is reliable, especially given that you say it works fine if you don't use that size.

I mean, if I don't send the form element that contains the file size it works, if I do send it, even if empty, the stream is incomplete, based on the file_size form value sent or the Content-Length header. This is strange because with standard HTTP works just fine... Anyways, that is reliable, as I said, with HTTP works fine.

Perhaps you're calculating the file size incorrectly? The form element you're sending will be part of the overall body content-length.

Perhaps you're calculating the file size incorrectly?

I am not calculating the size, I am using inputFile.files[0].size.

The form element you're sending will be part of the overall body content-length.

I know that it will be, but, the size would be a bit bigger, not smaller

Yes, but then you're sending that as part of the request body. That is included in the content-length header.

Yes, but then you're sending that as part of the request body. That is included in the content-length header.

ikr, the sizeLimit is at 1.5gb, so I don't think it's a body size problem

I know that it will be, but, the size would be a bit bigger, not smaller

That's the point, the content-length header is now bigger than the file you're receiving.

Let's discuss on IRC, can post here when we figure it out.

I was doing some tests with this file, it has some javascript that sends the file size, and if the script doesn't find it, it falls back to content-length.
result
That's the result I've got. So the file length is exact...

(I've used these certificates: https://github.com/amphp/http-server/tree/master/tools/tls, testing on localhost.)

I should have realized when you said it didn't work with HTTPS that it was likely using HTTP/2, so I should have looked at the HTTP/2 driver for the issue.

Can you please try with http-server @ dev-master and let me know if that fixes the issue.

I should have realized when you said it didn't work with HTTPS that it was likely using HTTP/2, so I should have looked at the HTTP/2 driver for the issue.

Can you please try with http-server @ dev-master and let me know if that fixes the issue.

Ok, I'll tell you in a moment

I should have realized when you said it didn't work with HTTPS that it was likely using HTTP/2, so I should have looked at the HTTP/2 driver for the issue.

Can you please try with http-server @ dev-master and let me know if that fixes the issue.

Nope, still the same... Maybe it's my code that's wrong?

No, I don't think your code is wrong, there's something strange going on. I've been looking at it this morning but didn't get anywhere yet. Will investigate further soon.

Maybe moving this issue to http-server? So that you have everything good & organized?

Fixed by amphp/http-server#304 and released in http-server@2.1.0.