mirror of https://github.com/status-im/metro.git
Clean not found/error requests from nodejs HTTP agent
Differential Revision: D7635421 fbshipit-source-id: 2a825a99ce57857354f17496239a9537bf068bc2
This commit is contained in:
parent
f5e93c6e91
commit
8fcc40edf2
|
@ -77,11 +77,16 @@ class HttpStore {
|
||||||
const req = this._module.request(options, res => {
|
const req = this._module.request(options, res => {
|
||||||
let data = '';
|
let data = '';
|
||||||
|
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
// Consume all the data from the response without processing it.
|
||||||
|
res.resume();
|
||||||
|
|
||||||
if (res.statusCode === 404) {
|
if (res.statusCode === 404) {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
return;
|
} else {
|
||||||
} else if (res.statusCode !== 200) {
|
|
||||||
reject(new Error('HTTP error: ' + res.statusCode));
|
reject(new Error('HTTP error: ' + res.statusCode));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +140,9 @@ class HttpStore {
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Consume all the data from the response without processing it.
|
||||||
|
res.resume();
|
||||||
});
|
});
|
||||||
|
|
||||||
gzip.pipe(req);
|
gzip.pipe(req);
|
||||||
|
|
Loading…
Reference in New Issue