Skip to content

Commit c4e8cee

Browse files
Merge pull request #69 from ConvertAPI/feature/keepalive
Enable keepalive by default with an option to disable
2 parents d211bb8 + 10b3785 commit c4e8cee

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ var convertapi = require('convertapi')('your-api-secret', {
5050
username: 'testuser',
5151
password: 'secret'
5252
}
53-
}
53+
},
54+
keepAlive: true
5455
});
5556
```
5657

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface Options {
55
downloadTimeout?: number;
66
proxy?: object;
77
baseUri?: string;
8+
keepAlive?: boolean;
89
}
910

1011
export interface ResultFile {

src/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
22
import fs from 'fs';
3+
import https from 'https';
34
import { buildQueryString, encodeFileName } from './utils';
45
import UploadResult from './upload_result';
56
import Error from './error';
@@ -91,6 +92,7 @@ export default class Client {
9192
maxBodyLength: Infinity,
9293
timeout: this.api.uploadTimeout * 1000,
9394
proxy: this.api.proxy,
95+
httpsAgent: new https.Agent({ keepAlive: this.api.keepAlive }),
9496
};
9597

9698
return axios(options)

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function ConvertAPI(secret, options = {}) {
1717
this.downloadTimeout = options.downloadTimeout || 1800;
1818
this.userAgent = `ConvertAPI-Node/${pkg.version}`;
1919
this.proxy = options.proxy;
20+
this.keepAlive = options.keepAlive !== undefined ? options.keepAlive : true;
2021

2122
this.client = new Client(this);
2223
}

0 commit comments

Comments
 (0)