Skip to content

Commit

Permalink
Documenting request options
Browse files Browse the repository at this point in the history
  • Loading branch information
rorticus committed Aug 1, 2017
1 parent bbf0f44 commit 1295599
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/request/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,39 @@ export type Provider = (url: string, options?: RequestOptions) => UploadObservab
export type ProviderTest = (url: string, options?: RequestOptions) => boolean | null;

export interface RequestOptions {
/**
* Enable cache busting (default false). Cache busting will make a new URL by appending a parameter to the
* requested URL
*/
cacheBust?: boolean;
credentials?: 'omit' | 'same-origin' | 'include';
/**
* Body to send along with the http request
*/
body?: Blob | BufferSource | FormData | UrlSearchParams | string;
/**
* Headers to send along with the http request
*/
headers?: Headers | { [key: string]: string; };
/**
* HTTP method
*/
method?: string;
/**
* Password for HTTP authentication
*/
password?: string;
/**
* Number of milliseconds before the request times out and is canceled
*/
timeout?: number;
/**
* User for HTTP authentication
*/
user?: string;
/**
* Optional query parameter(s) for the URL. The requested url will have these query parameters appended.
*/
query?: string | ParamList;
}

Expand Down
73 changes: 72 additions & 1 deletion src/request/providers/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,105 @@ import Observable from '../../Observable';
import SubscriptionPool from '../SubscriptionPool';

/**
* Request options specific to a node request
* Request options specific to a node request. For HTTPS options, see
* https://nodejs.org/api/tls.html#tls_tls_connect_options_callback for more details.
*/
export interface NodeRequestOptions extends RequestOptions {
/**
* User-agent header
*/
agent?: any;
/**
* If specified, the request body is read from the stream specified here, rather than from the `body` field.
*/
bodyStream?: Readable;
/**
* HTTPS optionally override the trusted CA certificates
*/
ca?: any;
/**
* HTTPS optional cert chains in PEM format. One cert chain should be provided per private key.
*/
cert?: string;
/**
* HTTPS optional cipher suite specification
*/
ciphers?: string;
dataEncoding?: string;
/**
* Whether or not to automatically follow redirects (default true)
*/
followRedirects?: boolean;
/**
* HTTPS optional private key in PEM format.
*/
key?: string;
/**
* Local interface to bind for network connections.
*/
localAddress?: string;
/**
* HTTPS optional shared passphrase used for a single private key and/or a PFX.
*/
passphrase?: string;
/**
* HTTPS optional PFX or PKCS12 encoded private key and certificate chain.
*/
pfx?: any;
/**
* Optional proxy address. If specified, requests will be sent through this url.
*/
proxy?: string;
/**
* HTTPS If not false the server will reject any connection which is not authorized with the list of supplied CAs
*/
rejectUnauthorized?: boolean;
/**
* HTTPS optional SSL method to use, default is "SSLv23_method"
*/
secureProtocol?: string;
/**
* Unix Domain Socket (use one of host:port or socketPath)
*/
socketPath?: string;
/**
* Whether or not to add the gzip and deflate accept headers (default true)
*/
acceptCompression?: boolean;
/**
* A set of options to set on the HTTP request
*/
socketOptions?: {
/**
* Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket.
*/
keepAlive?: number;
/**
* Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off.
*/
noDelay?: boolean;
/**
* Number of milliseconds before the HTTP request times out
*/
timeout?: number;
};
/**
* Stream encoding on incoming HTTP response
*/
streamEncoding?: string;
/**
* Options to control redirect follow logic
*/
redirectOptions?: {
/**
* The limit to the number of redirects that will be followed (default 15). This is used to prevent infinite
* redirect loops.
*/
limit?: number;
count?: number;
/**
* Whether or not to keep the original HTTP method during 301 redirects (default false).
*/
keepOriginalMethod?: boolean;
};
}
Expand Down
7 changes: 7 additions & 0 deletions src/request/providers/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ import SubscriptionPool from '../SubscriptionPool';
* Request options specific to an XHR request
*/
export interface XhrRequestOptions extends RequestOptions {
/**
* Controls whether or not the request is synchronous (blocks the main thread) or asynchronous (default).
*/
blockMainThread?: boolean;
/**
* Controls whether or not the X-Requested-With header is added to the request (default true). Set to false to not
* include the header.
*/
includeRequestedWithHeader?: boolean;
}

Expand Down

0 comments on commit 1295599

Please sign in to comment.