Skip to content

Commit

Permalink
fix: add agent and retry settings to upload request
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed Jun 3, 2019
1 parent 6baf4df commit c17ae23
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import urljoin from 'url-join';
import got, { Response, GotJSONOptions } from 'got';
import got, { Response, GotJSONOptions, GotFormOptions, GotOptions, GotBodyOptions } from 'got';
import { Cookie } from 'tough-cookie';
import FormData from 'form-data';
import fs from 'fs';
Expand Down Expand Up @@ -204,10 +204,21 @@ export class Deluge implements TorrentClient {
}

const url = urljoin(this.config.baseUrl, '/upload');
const res = await got.post(url, {
const options: GotBodyOptions<any> = {
headers: form.getHeaders(),
body: form,
});
retry: 0,
}
// allow proxy agent
if (this.config.agent) {
options.agent = this.config.agent;
}

if (this.config.timeout) {
options.timeout = this.config.timeout;
}

const res = await got.post(url, options);
return JSON.parse(res.body);
}

Expand Down

0 comments on commit c17ae23

Please sign in to comment.