Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add httpOptions option #855

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ The default values are shown after each option key.
compress: true, // support gzip/deflate content encoding. false to disable
size: 0, // maximum response body size in bytes. 0 to disable
agent: null, // http(s).Agent instance or function that returns an instance (see below)
highWaterMark: 16384 // the maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
highWaterMark: 16384, // the maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
httpOptions: {} // additional options to include in http(s).request options that cannot be configured by the http(s).Agent override.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation, replace tab for space to be consistent

}
```

Expand Down Expand Up @@ -537,6 +538,13 @@ const fetch = require('node-fetch');
})();
```


#### HTTP Options

Additional options to pass to http.request.
See [`http.request`](https://nodejs.org/api/http.html#http_http_request_url_options_callback) for more information.


<a id="class-request"></a>

### Class: Request
Expand Down
2 changes: 2 additions & 0 deletions src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class Request extends Body {
this.counter = init.counter || input.counter || 0;
this.agent = init.agent || input.agent;
this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
this.httpOptions = init.httpOptions || input.httpOptions || {};
}

get method() {
Expand Down Expand Up @@ -203,6 +204,7 @@ export const getNodeRequestOptions = request => {

// Manually spread the URL object instead of spread syntax
const requestOptions = {
...request.httpOptions,
path: parsedURL.pathname + search,
pathname: parsedURL.pathname,
hostname: parsedURL.hostname,
Expand Down