- add some specs

- prepare new "follow redirect" config interface
This commit is contained in:
Sefa Ilkimen
2019-04-15 04:23:03 +02:00
parent 7ba0852698
commit ccabbf2a29
5 changed files with 60 additions and 11 deletions
+9
View File
@@ -178,6 +178,14 @@ module.exports = function init(jsUtil, cookieHandler, messages) {
return timeout;
}
function checkFollowRedirectValue(follow) {
if (jsUtil.getTypeOf(follow) !== 'Boolean') {
throw new Error(messages.INVALID_FOLLOW_REDIRECT_VALUE);
}
return follow;
}
function checkHeadersObject(headers) {
return checkKeyValuePairObject(headers, ['String'], messages.INVALID_HEADERS_VALUE);
}
@@ -295,6 +303,7 @@ module.exports = function init(jsUtil, cookieHandler, messages) {
method: checkHttpMethod(options.method || validHttpMethods[0]),
serializer: checkSerializer(options.serializer || globals.serializer),
timeout: checkTimeoutValue(options.timeout || globals.timeout),
followRedirect: checkFollowRedirectValue(options.followRedirect || globals.followRedirect),
headers: checkHeadersObject(options.headers || {}),
params: checkParamsObject(options.params || {}),
data: jsUtil.getTypeOf(options.data) === 'Undefined' ? null : options.data,