Proxying of large files fail on Crystal 1.3.x
SamantazFox opened this issue · comments
Description
The stdlib override of HTTP::Server::Response::Output.close
is truncating server responses early when a large chunk of data is being proxied under Crystal 1.3.*
Steps to Reproduce
- Make a kemal-base application
- Add a route that will proxy content from another server (large files)
- In the route block, first copy headers, then
IO.copy
the data between the (other) server's response and the client - Response is truncated
Expected behavior: TCP stream closes normally
Actual behavior: TCP stream is unexpectedly closed before the end of the transfer.
Reproduces how often: always
Versions
Crystal v1.3.x
Additional Information
Conversation on Crystal's gitter:
https://gitter.im/crystal-lang/crystal?at=6212823f9a09ab24f36baeb1
https://gitter.im/crystal-lang/crystal?at=62129708c61ef0178e3a0e08
(and the whole conversation around)
The bug at invidious: iv-org/invidious#2783
Note: kudos to @Blacksmoke16 and moe:busyloop.net for their help!