Skip to content

Commit 1cf6ae3

Browse files
TUN-3896: http-service and tunnelstore client use http2 transport.
- If origin services are http2 and https is the service url, http2 transport is preferred. - The tunnelstore client is now upgraded to use http2.
1 parent 66da530 commit 1cf6ae3

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
**Experimental**: This is a new format for release notes. The format and availability is subject to change.
22

3+
## UNRELEASED
4+
5+
### Backward Incompatible Changes
6+
7+
- none
8+
9+
### New Features
10+
11+
- HTTP/2 transport is now always chosen if origin server supports it and the service url scheme is HTTPS.
12+
This was previously done in a best attempt manner.
13+
14+
### Improvements
15+
16+
- none
17+
18+
### Bug Fixes
19+
20+
- none
21+
322
## 2021.3.3
423

524
### Improvements

ingress/origin_service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/pkg/errors"
1616
"github.com/rs/zerolog"
1717

18+
"golang.org/x/net/http2"
19+
1820
"github.com/cloudflare/cloudflared/hello"
1921
"github.com/cloudflare/cloudflared/ipaccess"
2022
"github.com/cloudflare/cloudflared/socks"
@@ -287,6 +289,7 @@ func newHTTPTransport(service originService, cfg OriginRequestConfig, log *zerol
287289
httpTransport.DialContext = dialContext
288290
}
289291

292+
http2.ConfigureTransport(&httpTransport)
290293
return &httpTransport, nil
291294
}
292295

tunnelstore/client.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"github.com/pkg/errors"
1717
"github.com/rs/zerolog"
1818

19+
"golang.org/x/net/http2"
20+
1921
"github.com/cloudflare/cloudflared/teamnet"
2022
)
2123

@@ -247,6 +249,11 @@ func NewRESTClient(baseURL, accountTag, zoneTag, authToken, userAgent string, lo
247249
if err != nil {
248250
return nil, errors.Wrap(err, "failed to create account level endpoint")
249251
}
252+
httpTransport := http.Transport{
253+
TLSHandshakeTimeout: defaultTimeout,
254+
ResponseHeaderTimeout: defaultTimeout,
255+
}
256+
http2.ConfigureTransport(&httpTransport)
250257
return &RESTClient{
251258
baseEndpoints: &baseEndpoints{
252259
accountLevel: *accountLevelEndpoint,
@@ -256,11 +263,8 @@ func NewRESTClient(baseURL, accountTag, zoneTag, authToken, userAgent string, lo
256263
authToken: authToken,
257264
userAgent: userAgent,
258265
client: http.Client{
259-
Transport: &http.Transport{
260-
TLSHandshakeTimeout: defaultTimeout,
261-
ResponseHeaderTimeout: defaultTimeout,
262-
},
263-
Timeout: defaultTimeout,
266+
Transport: &httpTransport,
267+
Timeout: defaultTimeout,
264268
},
265269
log: log,
266270
}, nil

0 commit comments

Comments
 (0)