mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
fix(formdata): add hotfix to use the asynchronous API to compute the content-length header value; (#5521)
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -1576,6 +1576,10 @@ describe('supports http with nodejs', function () {
|
||||
it('should allow passing FormData', function (done) {
|
||||
var form = new FormDataLegacy();
|
||||
var file1 = Buffer.from('foo', 'utf8');
|
||||
const image = path.resolve(__dirname, './axios.png');
|
||||
const fileStream = fs.createReadStream(image);
|
||||
|
||||
const stat = fs.statSync(image);
|
||||
|
||||
form.append('foo', "bar");
|
||||
form.append('file1', file1, {
|
||||
@@ -1584,9 +1588,13 @@ describe('supports http with nodejs', function () {
|
||||
contentType: 'image/jpeg'
|
||||
});
|
||||
|
||||
form.append('fileStream', fileStream);
|
||||
|
||||
server = http.createServer(function (req, res) {
|
||||
var receivedForm = new formidable.IncomingForm();
|
||||
|
||||
assert.ok(req.rawHeaders.find(header => header.toLowerCase() === 'content-length'));
|
||||
|
||||
receivedForm.parse(req, function (err, fields, files) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
@@ -1609,6 +1617,10 @@ describe('supports http with nodejs', function () {
|
||||
assert.strictEqual(res.data.files.file1.originalFilename, 'temp/bar.jpg');
|
||||
assert.strictEqual(res.data.files.file1.size, 3);
|
||||
|
||||
assert.strictEqual(res.data.files.fileStream.mimetype, 'image/png');
|
||||
assert.strictEqual(res.data.files.fileStream.originalFilename, 'axios.png');
|
||||
assert.strictEqual(res.data.files.fileStream.size, stat.size);
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user