Repository navigation
Add async Content-Length computation when using form-data - #953
Conversation
|
how does |
|
We can see here: |
|
ok, the code is pretty obfuscated but it looks like it has some built in length retrievers for each stream that gets added to it. when those streams are known it can compute the length (if it has a .path property it'll fs.stat the path). I believe it errors when it doesn't understand the stream. In that case, you'll need to modify this patch so that when getLength's callback gets an error you just opt out of setting the length rather than actually emit an error in the stream. |
|
I updated the PR. (I updated my comment clarify. The problem was obviously not caused by async) There is a problem when the stream is created before the execution of the request. function doRequest (stream) {
var r = request.post('http://requestb.in/1baaynt1', function (err, httpResponse, body) {
if (err) {
throw err;
}
console.log(httpResponse, body);
});
var form = r.form();
form.append('file', stream);
}
// works
var stream = fs.createReadStream('test.jpg');
doRequest(stream);
// not works
var stream = fs.createReadStream('test.jpg');
setTimeout(function () {
doRequest(stream);
}, 100);I don't really know what happens but I continue to investigate... Any idea? (In my case, I |
|
@mikeal Any thought ? |
|
what version of node? |
|
Ok. Works great with |
|
Rebase done. Travis build in error caused by #951 |
|
Sorry this one took so long, I was busy with NodeConf :) |
Add async Content-Length computation when using form-data
|
Thanks for merging and your trust :) |
|
FYI... I ran into this same issue. We use Akamai. File uploads work fine locally, but not in production. Using the fix in this pull request resolved the issue. When will this get published? Thanks! |
Add async Content-Length computation when using form-data
Add async Content-Length computation when using form-data
Related to #345 #396 #522