Merge pull request #21585 from kevin-greene-ck/thrift-https

[thrift] connections should take options for http or https
This commit is contained in:
Nathan Shively-Sanders
2017-11-17 15:06:40 -08:00
committed by GitHub
2 changed files with 22 additions and 5 deletions
+2 -1
View File
@@ -10,6 +10,7 @@
import * as net from 'net';
import * as http from 'http';
import * as https from 'https';
import * as tls from 'tls';
// Thrift re-exports node-int64 and Q
@@ -249,7 +250,7 @@ export interface ConnectOptions {
retry_max_delay?: number;
connect_timeout?: number;
timeout?: number;
nodeOptions?: http.RequestOptions;
nodeOptions?: http.RequestOptions | https.RequestOptions;
}
export interface WSConnectOptions {
+20 -4
View File
@@ -1,4 +1,5 @@
import * as http from 'http';
import * as https from 'https';
import {
createConnection,
@@ -43,18 +44,33 @@ const mockGeneratedService = {
createServer<MockProcessor, MockServiceHandlers>(mockGeneratedService, mockServiceHandlers);
const nodeOptions: http.RequestOptions = {
const httpOptions: http.RequestOptions = {
timeout: 10000,
headers: {
'Content-Type': 'application/octet-stream'
}
};
const httpsOptions: https.RequestOptions = {
timeout: 10000,
headers: {
'Content-Type': 'application/octet-stream'
},
secureProtocol: 'SSLv3_method'
};
const clientConnection = createConnection('0.0.0.0', 1234, {
transport: TBufferedTransport,
protocol: TBinaryProtocol,
nodeOptions
transport: TBufferedTransport,
protocol: TBinaryProtocol,
nodeOptions: httpOptions
});
const secureConnection = createConnection('0.0.0.0', 1234, {
transport: TBufferedTransport,
protocol: TBinaryProtocol,
nodeOptions: httpsOptions
});
createClient<MockClient>(mockGeneratedService, clientConnection);
const mockBuffer: Buffer = Buffer.alloc(8);