Skip to content

Commit 048684a

Browse files
committed
update deps to drop h2c lib
1 parent abbe514 commit 048684a

File tree

6 files changed

+116
-86
lines changed

6 files changed

+116
-86
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,5 @@ require (
168168
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
169169
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
170170
)
171+
172+
replace knative.dev/pkg => github.com/dprotaso/pkg v0.0.0-20251130181829-779b85906b73

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBi
111111
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
112112
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
113113
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
114+
github.com/dprotaso/pkg v0.0.0-20251130181829-779b85906b73 h1:jMvzA7UOksGYqUOS67I4Wka/apQr9MbpmHyvulzuwDs=
115+
github.com/dprotaso/pkg v0.0.0-20251130181829-779b85906b73/go.mod h1:Eh9hwzqriXEfHiXcCuOYExUj7WH8prk57V6qSeO6m94=
114116
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
115117
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
116118
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -592,8 +594,6 @@ knative.dev/hack v0.0.0-20251126013634-1484a9e9b641 h1:N9Xqx3YLUNFN1WIc3UXTanK4j
592594
knative.dev/hack v0.0.0-20251126013634-1484a9e9b641/go.mod h1:L5RzHgbvam0u8QFHfzCX6MKxu/a/gIGEdaRBqNiVbl0=
593595
knative.dev/networking v0.0.0-20251126213812-ebe48fd53262 h1:CEFraQgj5csZPv2NgCA4h8Bz09BEUo5nFBOE552KV/8=
594596
knative.dev/networking v0.0.0-20251126213812-ebe48fd53262/go.mod h1:nxN+sYiQCoT2FLgSMTShXYmYYcb7rALHSOz6l5RjCp4=
595-
knative.dev/pkg v0.0.0-20251126013532-e853b1d1d6bb h1:JhpOj4b8wdTjbahkCyZUaFlkuHib/6uCVyjPI/W4MPg=
596-
knative.dev/pkg v0.0.0-20251126013532-e853b1d1d6bb/go.mod h1:KFRQGFIcsdi9fDto0lGkcz/NwnNr/8hq9mmLyBuLkro=
597597
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
598598
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
599599
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=

vendor/knative.dev/pkg/network/h2c.go

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2025 The Knative Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package network
18+
19+
import (
20+
"net/http"
21+
"time"
22+
)
23+
24+
func NewServer(addr string, h http.Handler) *http.Server {
25+
var protocols http.Protocols
26+
protocols.SetHTTP1(true)
27+
protocols.SetUnencryptedHTTP2(true)
28+
29+
return &http.Server{
30+
Addr: addr,
31+
Handler: h,
32+
Protocols: &protocols,
33+
34+
// https://medium.com/a-journey-with-go/go-understand-and-mitigate-slowloris-attack-711c1b1403f6
35+
ReadHeaderTimeout: time.Minute,
36+
}
37+
}

vendor/knative.dev/pkg/network/transports.go

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,61 +117,120 @@ func dialBackOffHelper(ctx context.Context, network, address string, bo wait.Bac
117117
return nil, fmt.Errorf("%w %s after %.2fs", ErrTimeoutDialing, address, elapsed.Seconds())
118118
}
119119

120-
func newHTTPTransport(disableKeepAlives, disableCompression bool, maxIdle, maxIdlePerHost int) http.RoundTripper {
120+
func newHTTPTransport(
121+
disableKeepAlives,
122+
disableCompression bool,
123+
maxIdle,
124+
maxIdlePerHost int,
125+
) *http.Transport {
126+
var protocols http.Protocols
127+
protocols.SetHTTP1(true)
128+
121129
transport := http.DefaultTransport.(*http.Transport).Clone()
122130
transport.DialContext = DialWithBackOff
123131
transport.DisableKeepAlives = disableKeepAlives
124132
transport.MaxIdleConns = maxIdle
125133
transport.MaxIdleConnsPerHost = maxIdlePerHost
126134
transport.ForceAttemptHTTP2 = false
127135
transport.DisableCompression = disableCompression
136+
transport.Protocols = &protocols
137+
128138
return transport
129139
}
130140

131141
type DialTLSContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
132142

133-
func newHTTPSTransport(disableKeepAlives, disableCompression bool, maxIdle, maxIdlePerHost int, tlsContext DialTLSContextFunc) http.RoundTripper {
143+
func newHTTPSTransport(
144+
disableKeepAlives,
145+
disableCompression bool,
146+
maxIdle,
147+
maxIdlePerHost int,
148+
tlsContext DialTLSContextFunc,
149+
) *http.Transport {
150+
var protocols http.Protocols
151+
protocols.SetHTTP1(true)
152+
134153
transport := http.DefaultTransport.(*http.Transport).Clone()
135154
transport.DisableKeepAlives = disableKeepAlives
136155
transport.MaxIdleConns = maxIdle
137156
transport.MaxIdleConnsPerHost = maxIdlePerHost
138157
transport.ForceAttemptHTTP2 = false
139158
transport.DisableCompression = disableCompression
140159
transport.DialTLSContext = tlsContext
160+
transport.Protocols = &protocols
141161

142162
return transport
143163
}
144164

145165
// NewProberTransport creates a RoundTripper that is useful for probing,
146166
// since it will not cache connections.
147167
func NewProberTransport() http.RoundTripper {
148-
return newAutoTransport(
149-
newHTTPTransport(true /*disable keep-alives*/, false /*disable auto-compression*/, 0, 0 /*no caching*/),
150-
NewH2CTransport())
168+
http := newHTTPTransport(
169+
true, /*disable keep-alives*/
170+
false, /*disable auto-compression*/
171+
0, /*max idle*/
172+
0, /*no caching*/
173+
)
174+
175+
// h2 prior knowledge
176+
h2 := http.Clone()
177+
h2.Protocols.SetHTTP1(false)
178+
h2.Protocols.SetUnencryptedHTTP2(true)
179+
180+
return newAutoTransport(http, h2)
151181
}
152182

153183
// NewProxyAutoTLSTransport is same with NewProxyAutoTransport but it has DialTLSContextFunc to create HTTPS request.
154184
func NewProxyAutoTLSTransport(maxIdle, maxIdlePerHost int, tlsContext DialTLSContextFunc) http.RoundTripper {
155-
return newAutoTransport(
156-
newHTTPSTransport(false /*disable keep-alives*/, true /*disable auto-compression*/, maxIdle, maxIdlePerHost, tlsContext),
157-
newH2Transport(true /*disable auto-compression*/, tlsContext))
185+
https := newHTTPSTransport(
186+
false, /*disable keep-alives*/
187+
true, /*disable auto-compression*/
188+
maxIdle,
189+
maxIdlePerHost,
190+
tlsContext,
191+
)
192+
193+
h2 := https.Clone()
194+
h2.Protocols.SetHTTP1(false)
195+
h2.Protocols.SetHTTP2(true)
196+
h2.Protocols.SetUnencryptedHTTP2(true)
197+
198+
return newAutoTransport(https, h2)
158199
}
159200

160201
// NewAutoTransport creates a RoundTripper that can use appropriate transport
161202
// based on the request's HTTP version.
162203
func NewAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper {
163-
return newAutoTransport(
164-
newHTTPTransport(false /*disable keep-alives*/, false /*disable auto-compression*/, maxIdle, maxIdlePerHost),
165-
newH2CTransport(false /*disable auto-compression*/))
204+
http := newHTTPTransport(
205+
false, /*disable keep-alives*/
206+
false, /*disable auto-compression*/
207+
maxIdle,
208+
maxIdlePerHost,
209+
)
210+
211+
h2 := http.Clone()
212+
h2.Protocols.SetHTTP1(false)
213+
h2.Protocols.SetUnencryptedHTTP2(true)
214+
215+
return newAutoTransport(http, h2)
166216
}
167217

168218
// NewProxyAutoTransport creates a RoundTripper suitable for use by a reverse
169219
// proxy. The returned transport uses HTTP or H2C based on the request's HTTP
170220
// version. The transport has DisableCompression set to true.
171221
func NewProxyAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper {
172-
return newAutoTransport(
173-
newHTTPTransport(false /*disable keep-alives*/, true /*disable auto-compression*/, maxIdle, maxIdlePerHost),
174-
newH2CTransport(true /*disable auto-compression*/))
222+
http := newHTTPTransport(
223+
false, /*disable keep-alives*/
224+
true, /*disable auto-compression*/
225+
maxIdle,
226+
maxIdlePerHost,
227+
)
228+
229+
h2 := http.Clone()
230+
h2.Protocols.SetHTTP1(false)
231+
h2.Protocols.SetUnencryptedHTTP2(true)
232+
233+
return newAutoTransport(http, h2)
175234
}
176235

177236
// AutoTransport uses h2c for HTTP2 requests and falls back to `http.DefaultTransport` for all others

vendor/modules.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ knative.dev/networking/pkg/http/proxy
15221522
knative.dev/networking/pkg/http/stats
15231523
knative.dev/networking/pkg/ingress
15241524
knative.dev/networking/pkg/prober
1525-
# knative.dev/pkg v0.0.0-20251126013532-e853b1d1d6bb
1525+
# knative.dev/pkg v0.0.0-20251126013532-e853b1d1d6bb => github.com/dprotaso/pkg v0.0.0-20251130181829-779b85906b73
15261526
## explicit; go 1.24.0
15271527
knative.dev/pkg/apiextensions/storageversion
15281528
knative.dev/pkg/apiextensions/storageversion/cmd/migrate
@@ -1669,3 +1669,4 @@ sigs.k8s.io/structured-merge-diff/v6/value
16691669
# sigs.k8s.io/yaml v1.6.0
16701670
## explicit; go 1.22
16711671
sigs.k8s.io/yaml
1672+
# knative.dev/pkg => github.com/dprotaso/pkg v0.0.0-20251130181829-779b85906b73

0 commit comments

Comments
 (0)