-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
There's plenty of issues with streams since node 0.10
This code will fail, but only under load. If the response is a file, it will be missing a few bytes from the beginning.
var requestObject = request(...)
// need to pause here requestObject.pause()
requestObject.on('response', function (resp) {
if(resp.statusCode===200){
requestObject.pipe(somewhere)
}else{
//retry...
}
});pausing requestObject saves the day, but it doesn't get resumed when you call requestObject.pipe and has to be resumed manually.
Now the other way:
if I pass an option:
formData:{
file: stream
}All's well, request is sent, but no content-type and filename set.
So I go on and do:
formData:{
file: {
value:stream,
options:{
filename: "whatever", //silently required, see https://github.com/felixge/node-form-data/issues/74
contentType: "text/xml"
}
}
}If stream is a plain string, all works well. If stream is a new node 0.10 stream, it hangs forever.
Seems serious to me.
This 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.
PS. I wrote the code in github textbox and tried to make indents with tab and space so it got submitted too early.