mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
fix(http): fixed a regression that caused the data stream to be interrupted for responses with non-OK HTTP statuses; (#7193)
This commit is contained in:
@@ -737,7 +737,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|||||||
|
|
||||||
if (responseType === 'stream') {
|
if (responseType === 'stream') {
|
||||||
response.data = responseStream;
|
response.data = responseStream;
|
||||||
settle(resolve, abort, response);
|
settle(resolve, reject, response);
|
||||||
} else {
|
} else {
|
||||||
const responseBuffer = [];
|
const responseBuffer = [];
|
||||||
let totalResponseBytes = 0;
|
let totalResponseBytes = 0;
|
||||||
|
|||||||
@@ -2665,6 +2665,23 @@ describe('supports http with nodejs', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not abort stream on settle rejection', async () => {
|
||||||
|
server = await startHTTPServer((req, res) => {
|
||||||
|
res.statusCode = 404;
|
||||||
|
res.end('OK');
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.get(LOCAL_SERVER_URL, {
|
||||||
|
responseType: 'stream'
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.fail('should be rejected');
|
||||||
|
} catch(err) {
|
||||||
|
assert.strictEqual(await getStream(err.response.data), 'OK');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user