mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
fix(fetch): fix headers getting from a stream response; (#6401)
This commit is contained in:
@@ -169,7 +169,7 @@ export default isFetchSupported && (async (config) => {
|
|||||||
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
||||||
const options = {};
|
const options = {};
|
||||||
|
|
||||||
Object.getOwnPropertyNames(response).forEach(prop => {
|
['status', 'statusText', 'headers'].forEach(prop => {
|
||||||
options[prop] = response[prop];
|
options[prop] = response[prop];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -380,4 +380,17 @@ describe('supports fetch with nodejs', function () {
|
|||||||
assert.strictEqual(err.cause && err.cause.code, 'ENOTFOUND');
|
assert.strictEqual(err.cause && err.cause.code, 'ENOTFOUND');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should get response headers', async () => {
|
||||||
|
server = await startHTTPServer((req, res) => {
|
||||||
|
res.setHeader('foo', 'bar');
|
||||||
|
res.end(req.url)
|
||||||
|
});
|
||||||
|
|
||||||
|
const {headers} = await fetchAxios.get('/', {
|
||||||
|
responseType: 'stream'
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(headers.get('foo'), 'bar');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user