@ -43,9 +43,9 @@ You can donate using Bitcoin, PayPal, Gratipay, Flattr, cash-in-mail, SEPA trans
## Contributing
Pull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the `src/` files, not the `lib/` files.
Pull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the `.coffee` files, not the `.js` files.
Build tool of choice is `babel`; simply run `npm run build` while developing, and it will watch for changes.
Build tool of choice is `gulp`; simply run `gulp` while developing, and it will watch for changes.
Be aware that by making a pull request, you agree to release your modifications under the licenses stated above.
function_createForOfIteratorHelper(o,allowArrayLike){varit;if(typeofSymbol==="undefined"||o[Symbol.iterator]==null){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeofo.length==="number"){if(it)o=it;vari=0;varF=functionF(){};return{s:F,n:functionn(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:functione(_e){throw_e;},f:F};}thrownewTypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}varnormalCompletion=true,didErr=false,err;return{s:functions(){it=o[Symbol.iterator]();},n:functionn(){varstep=it.next();normalCompletion=step.done;returnstep;},e:functione(_e2){didErr=true;err=_e2;},f:functionf(){try{if(!normalCompletion&&it.return!=null)it.return();}finally{if(didErr)throwerr;}}};}
function_nonIterableSpread(){thrownewTypeError("Invalid attempt to spread non-iterable instance");}
function_nonIterableSpread(){thrownewTypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}
message:"You cannot define both formFields/files and a raw inputStream or inputBuffer.",
request:request,
response:response,
requestState:requestState
}));
returnPromise.reject(addErrorData(newbhttpErrors.ConflictingOptionsError("You cannot define both formFields/files and a raw inputStream or inputBuffer."),request,response,requestState));
returnPromise.reject(addErrorData(newbhttpErrors.ConflictingOptionsError("You cannot use both encodeJSON and a raw inputStream or inputBuffer.",undefined,"If you meant to JSON-encode the stream, you will currently have to do so manually."),request,response,requestState));
}// If the user plans on streaming the response, we need to disable the agent entirely - otherwise the streams will block the pool.
@ -375,11 +372,12 @@ var preparePayload = function preparePayload(request, response, requestState) {
message:"Most servers do not support chunked transfer encoding for multipart/form-data payloads, and we could not determine the length of all the input streams. See the documentation for more information.",
request:request,
response:response,
requestState:requestState
}));
returnPromise.reject(addErrorData(newbhttpErrors.MultipartError("Most servers do not support chunked transfer encoding for multipart/form-data payloads, and we could not determine the length of all the input streams. See the documentation for more information."),request,response,requestState));
}else{
assign(request.options.headers,headers);
returnPromise.resolve();
@ -515,7 +517,7 @@ var makeRequest = function makeRequest(request, response, requestState) {
returnPromise.reject(newbhttpErrors.RedirectError("The maximum amount of redirects ({request.responseOptions.redirectLimit}) was reached."));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("The maximum amount of redirects ({request.responseOptions.redirectLimit}) was reached.")));
}// 301: For GET and HEAD, redirect unchanged. For POST, PUT, PATCH, DELETE, "ask user" (in our case: throw an error.)
// 302: Redirect, change method to GET.
// 303: Redirect, change method to GET.
@ -638,15 +649,10 @@ var processResponse = function processResponse(request, response, requestState)
message:"Encountered a 301 redirect for POST, PUT, PATCH or DELETE. RFC says we can't automatically continue.",
request:request,
response:response,
requestState:requestState
}));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("Encountered a 301 redirect for POST, PUT, PATCH or DELETE. RFC says we can't automatically continue."),request,response,requestState));
default:
returnPromise.reject(newbhttpErrors.RedirectError("Encountered a 301 redirect, but not sure how to proceed for the ".concat(request.options.method.toUpperCase()," method.")));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("Encountered a 301 redirect, but not sure how to proceed for the ".concat(request.options.method.toUpperCase()," method."))));
}
case302:
@ -655,12 +661,7 @@ var processResponse = function processResponse(request, response, requestState)
message:"Encountered a 307 redirect for POST, PUT or DELETE, but your payload contained (single-use) streams. We therefore can't automatically follow the redirect.",
request:request,
response:response,
requestState:requestState
}));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("Encountered a 307 redirect for POST, PUT or DELETE, but your payload contained (single-use) streams. We therefore can't automatically follow the redirect."),request,response,requestState));
returnPromise.reject(newbhttpErrors.ConflictingOptionsError({message:"You cannot define both formFields/files and a raw inputStream or inputBuffer.", request,response,requestState}));
returnPromise.reject(addErrorData(newbhttpErrors.ConflictingOptionsError("You cannot define both formFields/files and a raw inputStream or inputBuffer."), request,response,requestState));
message:"You cannot use both encodeJSON and a raw inputStream or inputBuffer.",
response:"If you meant to JSON-encode the stream, you will currently have to do so manually.",
request,
response,
requestState,
}));
returnPromise.reject(addErrorData(newbhttpErrors.ConflictingOptionsError("You cannot use both encodeJSON and a raw inputStream or inputBuffer.",undefined,"If you meant to JSON-encode the stream, you will currently have to do so manually."),request,response,requestState));
}
// If the user plans on streaming the response, we need to disable the agent entirely - otherwise the streams will block the pool.
returnPromise.reject(newbhttpErrors.MultipartError({message:"Most servers do not support chunked transfer encoding for multipart/form-data payloads, and we could not determine the length of all the input streams. See the documentation for more information.", request,response,requestState}));
returnPromise.reject(addErrorData(newbhttpErrors.MultipartError("Most servers do not support chunked transfer encoding for multipart/form-data payloads, and we could not determine the length of all the input streams. See the documentation for more information."), request,response,requestState));
returnPromise.reject(newbhttpErrors.RedirectError("The maximum amount of redirects ({request.responseOptions.redirectLimit}) was reached."));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("The maximum amount of redirects ({request.responseOptions.redirectLimit}) was reached.")));
}
// 301: For GET and HEAD, redirect unchanged. For POST, PUT, PATCH, DELETE, "ask user" (in our case: throw an error.)
returnPromise.reject(newbhttpErrors.RedirectError({message:"Encountered a 301 redirect for POST, PUT, PATCH or DELETE. RFC says we can't automatically continue.", request,response,requestState}));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("Encountered a 301 redirect for POST, PUT, PATCH or DELETE. RFC says we can't automatically continue."), request,response,requestState));
default:
returnPromise.reject(newbhttpErrors.RedirectError(`Encountered a 301 redirect, but not sure how to proceed for the ${request.options.method.toUpperCase()} method.`));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError(`Encountered a 301 redirect, but not sure how to proceed for the ${request.options.method.toUpperCase()} method.`)));
returnPromise.reject(newbhttpErrors.RedirectError({message:"Encountered a 307 redirect for POST, PUT or DELETE, but your payload contained (single-use) streams. We therefore can't automatically follow the redirect.", request,response,requestState}));
returnPromise.reject(addErrorData(newbhttpErrors.RedirectError("Encountered a 307 redirect for POST, PUT or DELETE, but your payload contained (single-use) streams. We therefore can't automatically follow the redirect."), request,response,requestState));