From 3c859b02bf5f064cd0f03e59ae3f7c6e5ca238b9 Mon Sep 17 00:00:00 2001 From: Matanel Sindilevich Date: Thu, 31 Aug 2017 22:49:29 +0300 Subject: [PATCH] Adding new RequestOptions --- types/needle/index.d.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/types/needle/index.d.ts b/types/needle/index.d.ts index 95fe47a5cf..0d686ea7d7 100644 --- a/types/needle/index.d.ts +++ b/types/needle/index.d.ts @@ -82,6 +82,16 @@ declare module "needle" { * instead of a query string. */ json?: boolean; + /** + * When sending streams, this lets manually set the Content-Length header + * --if the stream's bytecount is known beforehand--, + * preventing ECONNRESET (socket hang up) errors on some servers that misbehave + * when receiving payloads of unknown size. + * Set it to 0 and Needle will get and set the stream's length, + * or leave unset for the default behavior, + * which is no Content-Length header for stream payloads. + */ + stream_length?: number; // These properties are overwritten by those in the 'headers' field /** @@ -118,6 +128,15 @@ declare module "needle" { * Defaults to Needle/{version} (Node.js {node_version}). */ user_agent?: string; + /** + * Sets the 'Content-Type' header. + * Unset by default, unless you're sending data + * in which case it's set accordingly to whatever is being sent + * (application/x-www-form-urlencoded, application/json or multipart/form-data). + * That is, of course, unless the option is passed, + * either here or through options.headers. + */ + content_type?: string; } interface ResponseOptions {