{"action":"created","issue":{"url":"https://api.github.com/repos/request/request/issues/1402","labels_url":"https://api.github.com/repos/request/request/issues/1402/labels{/name}","comments_url":"https://api.github.com/repos/request/request/issues/1402/comments","events_url":"https://api.github.com/repos/request/request/issues/1402/events","html_url":"https://github.com/request/request/issues/1402","id":56397175,"number":1402,"title":"new streams support, please","user":{"login":"naugtur","id":509375,"avatar_url":"https://avatars.githubusercontent.com/u/509375?v=3","gravatar_id":"","url":"https://api.github.com/users/naugtur","html_url":"https://github.com/naugtur","followers_url":"https://api.github.com/users/naugtur/followers","following_url":"https://api.github.com/users/naugtur/following{/other_user}","gists_url":"https://api.github.com/users/naugtur/gists{/gist_id}","starred_url":"https://api.github.com/users/naugtur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naugtur/subscriptions","organizations_url":"https://api.github.com/users/naugtur/orgs","repos_url":"https://api.github.com/users/naugtur/repos","events_url":"https://api.github.com/users/naugtur/events{/privacy}","received_events_url":"https://api.github.com/users/naugtur/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-03T16:03:11Z","updated_at":"2015-06-08T21:39:16Z","closed_at":null,"body":"There's plenty of issues with streams since node 0.10 \r\n\r\nThis code will fail, but only under load. If the response is a file, it will be missing a few bytes from the beginning.\r\n```javascript\r\nvar requestObject = request(...)\r\n// need to pause here requestObject.pause()\r\nrequestObject.on('response', function (resp) {\r\n  if(resp.statusCode===200){\r\n    requestObject.pipe(somewhere)\r\n  }else{\r\n    //retry...\r\n  }\r\n});\r\n```\r\npausing `requestObject` saves the day, but it doesn't get resumed when you call `requestObject.pipe` and has to be resumed manually.\r\n\r\nNow the other way:\r\n\r\nif I pass an option:\r\n```javascript\r\nformData:{\r\n  file: stream\r\n}\r\n```\r\nAll's well, request is sent, but no content-type and filename set.\r\nSo I go on and do:\r\n```javascript\r\nformData:{\r\n  file: {\r\n    value:stream,\r\n    options:{\r\n      filename: \"whatever\", //silently required, see https://github.com/felixge/node-form-data/issues/74\r\n      contentType: \"text/xml\"\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nIf `stream` is a plain string, all works well. If `stream` is a new node 0.10 stream, it hangs forever.\r\n\r\nSeems serious to me.\r\n\r\nThis bug could be split in two if the first case can be fixed without intervention in `form-data`. In that case, let me know how I could help and where to start looking if I want to make a PR.\r\n\r\nPS. I wrote the code in github textbox and tried to make indents with tab and space so it got submitted too early.\r\n"},"comment":{"url":"https://api.github.com/repos/request/request/issues/comments/110148938","html_url":"https://github.com/request/request/issues/1402#issuecomment-110148938","issue_url":"https://api.github.com/repos/request/request/issues/1402","id":110148938,"user":{"login":"odnarb","id":8440432,"avatar_url":"https://avatars.githubusercontent.com/u/8440432?v=3","gravatar_id":"","url":"https://api.github.com/users/odnarb","html_url":"https://github.com/odnarb","followers_url":"https://api.github.com/users/odnarb/followers","following_url":"https://api.github.com/users/odnarb/following{/other_user}","gists_url":"https://api.github.com/users/odnarb/gists{/gist_id}","starred_url":"https://api.github.com/users/odnarb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odnarb/subscriptions","organizations_url":"https://api.github.com/users/odnarb/orgs","repos_url":"https://api.github.com/users/odnarb/repos","events_url":"https://api.github.com/users/odnarb/events{/privacy}","received_events_url":"https://api.github.com/users/odnarb/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T21:39:16Z","updated_at":"2015-06-08T21:39:16Z","body":"Still an issue. Seems there was some effort before?\r\n\r\nhttps://github.com/request/request/pull/660"}}