Skip to content

Commit 057c948

Browse files
feat: add optional httpsOptions parameter to NodeHttpTransport (#1122)
* feat: add optional httpsOptions parameter to NodeHttpTransport * Update go.mod Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>
1 parent 964037e commit 057c948

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

client/grpc-web-node-http-transport/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import * as https from "https";
33
import * as url from "url";
44
import { grpc } from "@improbable-eng/grpc-web";
55

6-
export function NodeHttpTransport(): grpc.TransportFactory {
6+
export function NodeHttpTransport(httpsOptions?: https.RequestOptions): grpc.TransportFactory {
77
return (opts: grpc.TransportOptions) => {
8-
return new NodeHttp(opts);
8+
return new NodeHttp(opts, httpsOptions);
99
};
1010
}
1111

1212
class NodeHttp implements grpc.Transport {
1313
options: grpc.TransportOptions;
1414
request: http.ClientRequest;
1515

16-
constructor(transportOptions: grpc.TransportOptions) {
16+
constructor(transportOptions: grpc.TransportOptions, readonly httpsOptions?: https.RequestOptions) {
1717
this.options = transportOptions;
1818
}
1919

@@ -61,7 +61,7 @@ class NodeHttp implements grpc.Transport {
6161
method: "POST"
6262
};
6363
if (parsedUrl.protocol === "https:") {
64-
this.request = https.request(httpOptions, this.responseCallback.bind(this));
64+
this.request = https.request({ ...httpOptions, ...this?.httpsOptions }, this.responseCallback.bind(this));
6565
} else {
6666
this.request = http.request(httpOptions, this.responseCallback.bind(this));
6767
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ require (
1616
github.com/sirupsen/logrus v1.7.0
1717
github.com/spf13/pflag v1.0.5
1818
github.com/stretchr/testify v1.7.0
19-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
20-
golang.org/x/text v0.3.7 // indirect
19+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
20+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
2121
google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506 // indirect
2222
google.golang.org/grpc v1.32.0
2323
google.golang.org/protobuf v1.27.1

go.sum

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
324324
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
325325
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
326326
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
327-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
328-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
327+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
328+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
329329
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
330330
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
331331
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -379,9 +379,13 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
379379
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
380380
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
381381
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
382-
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
382+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
383383
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
384+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
385+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
386+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
384387
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
388+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
385389
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
386390
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
387391
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

0 commit comments

Comments
 (0)