Compare commits

..

No commits in common. "support/v0.30" and "v0.30.3" have entirely different histories.

5 changed files with 25 additions and 24 deletions

View file

@ -4,12 +4,6 @@ This document outlines major changes between releases.
## [Unreleased] ## [Unreleased]
## [0.30.4] - 2025-02-18
### Fixed
- Dropped http2 forcing (#216)
## [0.30.3] - 2024-10-18 ## [0.30.3] - 2024-10-18
### Fixed ### Fixed
@ -152,6 +146,5 @@ To see CHANGELOG for older versions, refer to https://github.com/nspcc-dev/neofs
[0.30.0]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.29.0...v0.30.0 [0.30.0]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.29.0...v0.30.0
[0.30.1]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.0...v0.30.1 [0.30.1]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.0...v0.30.1
[0.30.2]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.1...v0.30.2 [0.30.2]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.1...v0.30.2
[0.30.3]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.2...v0.30.3 [0.30.2]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.2...v0.30.3
[0.30.4]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.3...v0.30.4 [Unreleased]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.3...master
[Unreleased]: https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/compare/v0.30.4...master

View file

@ -1 +1 @@
v0.30.4 v0.30.3

View file

@ -74,6 +74,7 @@ func newServer(ctx context.Context, serverInfo ServerInfo) (*server, error) {
ln = tls.NewListener(ln, &tls.Config{ ln = tls.NewListener(ln, &tls.Config{
GetCertificate: tlsProvider.GetCertificate, GetCertificate: tlsProvider.GetCertificate,
NextProtos: []string{"h2"}, // required to enable HTTP/2 requests in `http.Serve`
}) })
} }

View file

@ -18,7 +18,7 @@ import (
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/valyala/fasthttp" "golang.org/x/net/http2"
) )
const ( const (
@ -26,10 +26,14 @@ const (
expHeaderValue = "Bar" expHeaderValue = "Bar"
) )
func TestHTTP_TLS(t *testing.T) { func TestHTTP2TLS(t *testing.T) {
ctx := context.Background() ctx := context.Background()
certPath, keyPath := prepareTestCerts(t) certPath, keyPath := prepareTestCerts(t)
srv := &http.Server{
Handler: http.HandlerFunc(testHandler),
}
tlsListener, err := newServer(ctx, ServerInfo{ tlsListener, err := newServer(ctx, ServerInfo{
Address: ":0", Address: ":0",
TLS: ServerTLSInfo{ TLS: ServerTLSInfo{
@ -43,34 +47,37 @@ func TestHTTP_TLS(t *testing.T) {
addr := fmt.Sprintf("https://localhost:%d", port) addr := fmt.Sprintf("https://localhost:%d", port)
go func() { go func() {
_ = fasthttp.Serve(tlsListener.Listener(), testHandler) _ = srv.Serve(tlsListener.Listener())
}() }()
// Server is running, now send HTTP/2 request
tlsClientConfig := &tls.Config{ tlsClientConfig := &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
} }
cliHTTP := http.Client{Transport: &http.Transport{}} cliHTTP1 := http.Client{Transport: &http.Transport{TLSClientConfig: tlsClientConfig}}
cliHTTPS := http.Client{Transport: &http.Transport{TLSClientConfig: tlsClientConfig}} cliHTTP2 := http.Client{Transport: &http2.Transport{TLSClientConfig: tlsClientConfig}}
req, err := http.NewRequest("GET", addr, nil) req, err := http.NewRequest("GET", addr, nil)
require.NoError(t, err) require.NoError(t, err)
req.Header[expHeaderKey] = []string{expHeaderValue} req.Header[expHeaderKey] = []string{expHeaderValue}
resp, err := cliHTTPS.Do(req) resp, err := cliHTTP1.Do(req)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode) require.Equal(t, http.StatusOK, resp.StatusCode)
_, err = cliHTTP.Do(req) resp, err = cliHTTP2.Do(req)
require.ErrorContains(t, err, "failed to verify certificate") require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode)
} }
func testHandler(ctx *fasthttp.RequestCtx) { func testHandler(resp http.ResponseWriter, req *http.Request) {
hdr := ctx.Request.Header.Peek(expHeaderKey) hdr, ok := req.Header[expHeaderKey]
if len(hdr) == 0 || string(hdr) != expHeaderValue { if !ok || len(hdr) != 1 || hdr[0] != expHeaderValue {
ctx.Response.SetStatusCode(http.StatusBadRequest) resp.WriteHeader(http.StatusBadRequest)
} else { } else {
ctx.Response.SetStatusCode(http.StatusOK) resp.WriteHeader(http.StatusOK)
} }
} }

2
go.mod
View file

@ -23,6 +23,7 @@ require (
go.opentelemetry.io/otel/trace v1.16.0 go.opentelemetry.io/otel/trace v1.16.0
go.uber.org/zap v1.27.0 go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
golang.org/x/net v0.23.0
google.golang.org/grpc v1.62.0 google.golang.org/grpc v1.62.0
) )
@ -103,7 +104,6 @@ require (
go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect