Use node-fetch instead of request (#6228)
* requestをnode-fetchになど * format * fix error * t * Fix test
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import * as request from 'request-promise-native';
|
||||
import { getJson } from '../../misc/fetch';
|
||||
import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type';
|
||||
import config from '../../config';
|
||||
|
||||
export default class Resolver {
|
||||
private history: Set<string>;
|
||||
private timeout = 10 * 1000;
|
||||
|
||||
constructor() {
|
||||
this.history = new Set();
|
||||
@@ -41,24 +39,7 @@ export default class Resolver {
|
||||
|
||||
this.history.add(value);
|
||||
|
||||
const object = await request({
|
||||
url: value,
|
||||
proxy: config.proxy,
|
||||
timeout: this.timeout,
|
||||
forever: true,
|
||||
headers: {
|
||||
'User-Agent': config.userAgent,
|
||||
Accept: 'application/activity+json, application/ld+json'
|
||||
},
|
||||
json: true
|
||||
}).catch(e => {
|
||||
const message = `${e.name}: ${e.message ? e.message.substr(0, 200) : undefined}, url=${value}`;
|
||||
throw {
|
||||
name: e.name,
|
||||
statusCode: e.statusCode,
|
||||
message,
|
||||
};
|
||||
});
|
||||
const object = await getJson(value, 'application/activity+json, application/ld+json');
|
||||
|
||||
if (object == null || (
|
||||
Array.isArray(object['@context']) ?
|
||||
|
Reference in New Issue
Block a user