mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
Added https methods for superagent's Request
This commit is contained in:
Vendored
+4
@@ -98,15 +98,19 @@ declare namespace request {
|
||||
attach(field: string, file: Blob | Buffer | fs.ReadStream | string, filename?: string): this;
|
||||
auth(user: string, name: string): this;
|
||||
buffer(val?: boolean): this;
|
||||
ca(cert: Buffer): this;
|
||||
cert(cert: Buffer | string): this;
|
||||
clearTimeout(): this;
|
||||
end(callback?: CallbackHandler): this;
|
||||
field(name: string, val: string): this;
|
||||
get(field: string): string;
|
||||
key(cert: Buffer | string): this;
|
||||
on(name: 'error', handler: (err: any) => void): this;
|
||||
on(name: 'progress', handler: (event: ProgressEvent) => void): this;
|
||||
on(name: string, handler: (event: any) => void): this;
|
||||
parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this;
|
||||
part(): this;
|
||||
pfx(cert: Buffer | string): this;
|
||||
pipe(stream: NodeJS.WritableStream, options?: object): stream.Writable;
|
||||
query(val: object | string): this;
|
||||
redirects(n: number): this;
|
||||
|
||||
@@ -345,3 +345,20 @@ request
|
||||
assert(res.xhr instanceof XMLHttpRequest);
|
||||
assert(res.xhr.response instanceof Blob);
|
||||
});
|
||||
|
||||
// HTTPS request, from: https://github.com/visionmedia/superagent/commit/6158efbf42cb93d77c1a70887284be783dd7dabe
|
||||
const ca = fs.readFileSync('ca.cert.pem');
|
||||
const key = fs.readFileSync('key.pem');
|
||||
const cert = fs.readFileSync('cert.pem');
|
||||
request
|
||||
.post('/secure')
|
||||
.ca(ca)
|
||||
.key(key)
|
||||
.cert(cert)
|
||||
.end(callback);
|
||||
|
||||
const pfx = fs.readFileSync('cert.pfx');
|
||||
request
|
||||
.post('/secure')
|
||||
.pfx(pfx)
|
||||
.end(callback);
|
||||
|
||||
Reference in New Issue
Block a user