kemalcr / kemal

Fast, Effective, Simple Web Framework

Home Page:https://kemalcr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Make a kemal-base application
  2. Add a route that will proxy content from another server (large files)
  3. In the route block, first copy headers, then IO.copy the data between the (other) server's response and the client
  4. 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!