Remove request and request-promise from dev dependencies (#5077)

* removes from emailverificationtoken spec

* updates winston

* Updates ValidationAndPasswordsReset

* Use local request in schemas

* Removes request in rest.spec

* Removes request from PushRouter0

* removes request from public API

* removes request from index.spec

* Removes request form parse.push spec

* removes request from ParseInstallation spec

* Removes from ParseHooks

* removes request from ParseGlobalConfig.spec

* Removes request from ParseAPI.spec.js

* removes request from LogsRouter

* removes in features

* Filters undefined headers instead of crashing

* Removes request from ParseUser spec

* Removes usage of request in ParseFile.spec.js

* Removes request from AuthAdapters.js

* removes request-promise from ParseGeoPoint.spec

* Removes request-promise from ParseQuery spec

* remove request-promise from UserPII

* removes request-promise from EnableExpressErrorHandler

* Updates RevocableSessionUpgrade spec

* Update RestQuery

* Removes read preferenceOptionM

* ensure we forward auth from URL

* use request in CloudCode.spec.js

* Removes request-promise from JobSchedule.spec

* Removes rp from VerifyUserPassword.spec.js

* Removes rp from PasswordPolicy spec

* Removes rp from ParsePolygon spec

* Removes rp from fullTextSearch spec

* Removes rp from PArseQuery.Aggregate

* Ensure we properly forward errors

* Removes request and request-promise
This commit is contained in:
Florent Vilmart
2018-09-24 17:07:51 -04:00
committed by GitHub
parent 93a0017b25
commit 045d941aef
35 changed files with 5825 additions and 8257 deletions

View File

@@ -2,7 +2,7 @@ import HTTPResponse from './HTTPResponse';
import querystring from 'querystring';
import log from '../logger';
import { http, https } from 'follow-redirects';
import { URL } from 'url';
import { parse } from 'url';
const clients = {
'http:': http,
@@ -93,7 +93,7 @@ const encodeBody = function({ body, headers = {} }) {
module.exports = function httpRequest(options) {
let url;
try {
url = new URL(options.url);
url = parse(options.url);
} catch (e) {
return Promise.reject(e);
}
@@ -117,6 +117,19 @@ module.exports = function httpRequest(options) {
encoding: null,
followRedirects: options.followRedirects === true,
};
if (requestOptions.headers) {
Object.keys(requestOptions.headers).forEach(key => {
if (typeof requestOptions.headers[key] === 'undefined') {
delete requestOptions.headers[key];
}
});
}
if (url.search) {
options.qs = Object.assign({}, options.qs, querystring.parse(url.query));
}
if (url.auth) {
requestOptions.auth = url.auth;
}
if (options.qs) {
requestOptions.path += `?${querystring.stringify(options.qs)}`;
}
@@ -131,6 +144,9 @@ module.exports = function httpRequest(options) {
if (options.body) {
req.write(options.body);
}
req.on('error', error => {
reject(error);
});
req.end();
});
};