{"action":"created","issue":{"url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3367","repository_url":"https://api.github.com/repos/ipfs/go-ipfs","labels_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3367/labels{/name}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3367/comments","events_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3367/events","html_url":"https://github.com/ipfs/go-ipfs/issues/3367","id":187849756,"number":3367,"title":"If a command output writer writes 4096 bytes before it completed reading it's input, it won't be able to read the rest when using the HTTP API","user":{"login":"keks","id":146678,"avatar_url":"https://avatars.githubusercontent.com/u/146678?v=3","gravatar_id":"","url":"https://api.github.com/users/keks","html_url":"https://github.com/keks","followers_url":"https://api.github.com/users/keks/followers","following_url":"https://api.github.com/users/keks/following{/other_user}","gists_url":"https://api.github.com/users/keks/gists{/gist_id}","starred_url":"https://api.github.com/users/keks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keks/subscriptions","organizations_url":"https://api.github.com/users/keks/orgs","repos_url":"https://api.github.com/users/keks/repos","events_url":"https://api.github.com/users/keks/events{/privacy}","received_events_url":"https://api.github.com/users/keks/received_events","type":"User","site_admin":false},"labels":[{"id":374710706,"url":"https://api.github.com/repos/ipfs/go-ipfs/labels/api","name":"api","color":"1d76db","default":false},{"id":109732110,"url":"https://api.github.com/repos/ipfs/go-ipfs/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-11-07T22:36:40Z","updated_at":"2016-11-11T03:11:56Z","closed_at":null,"body":"I stumbled upon this when researching #3336.\r\n\r\nWhen the HTTP API receives a request, it starts the command using the HTTP arguments as arguments to the commands and feeds the request body to the command \"as stdin\". The command also has an stdout, which is an `io. Reader` on the caller's side.\r\nWhen you write to an `http.ResponseWriter`, all unconsumed data in the request body is lost.\r\nTo send the command result to the client, [`flushCopy`] is called with `r` being the command output and `w` being the `http.ResponseWriter`.\r\n\r\nAt the end of the first iteration, the connection is being flushed and the response headers are sent. If the request has not been fully consumed until then, it will be truncated.\r\nThe problem is that the information whether the input has been consumed is not available inside `flushCopy`, so to fix this we need to find a way do pass it.\r\n\r\nThe reason I think this is important is that at the moment when you subscribe a pubsub topic they headers are not being sent until that `Flush()` after the read is called. This way the all Go clients will block when sending their request, because they wait for the headers.\r\nThat is also the reason I added a `Flush` at the loop top in the first place. I wasn't aware that you couldn't read the body afterwards.\r\n\r\n[`flushCopy`]: https://github.com/ipfs/go-ipfs/blob/master/commands/http/handler.go#L294"},"comment":{"url":"https://api.github.com/repos/ipfs/go-ipfs/issues/comments/259870651","html_url":"https://github.com/ipfs/go-ipfs/issues/3367#issuecomment-259870651","issue_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3367","id":259870651,"user":{"login":"whyrusleeping","id":1243164,"avatar_url":"https://avatars.githubusercontent.com/u/1243164?v=3","gravatar_id":"","url":"https://api.github.com/users/whyrusleeping","html_url":"https://github.com/whyrusleeping","followers_url":"https://api.github.com/users/whyrusleeping/followers","following_url":"https://api.github.com/users/whyrusleeping/following{/other_user}","gists_url":"https://api.github.com/users/whyrusleeping/gists{/gist_id}","starred_url":"https://api.github.com/users/whyrusleeping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whyrusleeping/subscriptions","organizations_url":"https://api.github.com/users/whyrusleeping/orgs","repos_url":"https://api.github.com/users/whyrusleeping/repos","events_url":"https://api.github.com/users/whyrusleeping/events{/privacy}","received_events_url":"https://api.github.com/users/whyrusleeping/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T03:11:56Z","updated_at":"2016-11-11T03:11:56Z","body":"@keks Ah, okay. So we should do some special handling there, and make it clear that you should use multipart if you intend on being in that scenario."}}
{"actor":{"display_login":"whyrusleeping"}}