{"action":"created","issue":{"url":"https://api.github.com/repos/socketry/falcon/issues/4","repository_url":"https://api.github.com/repos/socketry/falcon","labels_url":"https://api.github.com/repos/socketry/falcon/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/socketry/falcon/issues/4/comments","events_url":"https://api.github.com/repos/socketry/falcon/issues/4/events","html_url":"https://github.com/socketry/falcon/pull/4","id":330405278,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzNDI0MjY0","number":4,"title":"Make Falcon::Adapters::Input#read behave like IO#read","user":{"login":"janko-m","id":795488,"node_id":"MDQ6VXNlcjc5NTQ4OA==","avatar_url":"https://avatars2.githubusercontent.com/u/795488?v=4","gravatar_id":"","url":"https://api.github.com/users/janko-m","html_url":"https://github.com/janko-m","followers_url":"https://api.github.com/users/janko-m/followers","following_url":"https://api.github.com/users/janko-m/following{/other_user}","gists_url":"https://api.github.com/users/janko-m/gists{/gist_id}","starred_url":"https://api.github.com/users/janko-m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janko-m/subscriptions","organizations_url":"https://api.github.com/users/janko-m/orgs","repos_url":"https://api.github.com/users/janko-m/repos","events_url":"https://api.github.com/users/janko-m/events{/privacy}","received_events_url":"https://api.github.com/users/janko-m/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2018-06-07T19:29:22Z","updated_at":"2018-06-08T14:11:10Z","closed_at":"2018-06-07T21:56:05Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/socketry/falcon/pulls/4","html_url":"https://github.com/socketry/falcon/pull/4","diff_url":"https://github.com/socketry/falcon/pull/4.diff","patch_url":"https://github.com/socketry/falcon/pull/4.patch"},"body":"Hello @ioquatix!\r\n\r\nI'm trying to make [tus-ruby-server](https://github.com/janko-m/tus-ruby-server) run on Falcon, as I was very impressed with its capabilities. Currently I'm recommending running tus-ruby-server on Goliath, but Goliath drags a lot of baggage which I don't need, and I needed to monkey-patch `#require` to make it work with Rack 2 (because of `async-rack`). So I would really like tus-ruby-server users to be able to use Falcon instead.\r\n\r\nFalcon::Adapters::Input#read at the moment doesn't respect the output buffer argument when length is given. This makes IO.copy_stream not behave correctly when a Falcon::Adapters::Input object is used as the source argument. And tus-ruby-server calls IO.copy_stream on the Rack input.\r\n\r\nThis PR modifies Falcon::Adapters::Input#read to append retrieved data to the output buffer. The output buffer is now also cleared beforehand, just like in IO#read.\r\n\r\nWe also return nil when EOF was reached and length argument was given, like IO#read. When length is 0, IO#read always returns an empty string, so we handle that case as well (even though it's rather peculiar)."},"comment":{"url":"https://api.github.com/repos/socketry/falcon/issues/comments/395773132","html_url":"https://github.com/socketry/falcon/pull/4#issuecomment-395773132","issue_url":"https://api.github.com/repos/socketry/falcon/issues/4","id":395773132,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTc3MzEzMg==","user":{"login":"tarcieri","id":797,"node_id":"MDQ6VXNlcjc5Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/797?v=4","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"created_at":"2018-06-08T14:11:10Z","updated_at":"2018-06-08T14:11:10Z","author_association":"NONE","body":"> For my use case it's important for `#read` to allocate the least amount of strings, because tus-ruby-server is intended to handle large file uploads (such as videos), so the Rack input will be retrieving lot of data.\r\n\r\nNote that this is exactly the sort of use case `NIO::ByteBuffer` is for:\r\n\r\nhttps://github.com/socketry/nio4r/wiki/Byte-Buffers\r\n\r\nFor `copy_stream`-style use cases where `copy_stream` won't suffice, it can avoid any allocations as well as the insanity of MRI I/O."}}
{"actor":{"display_login":"tarcieri"}}