Skip to content

Commit

Permalink
feat: use H2C for non-TLS client connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Bourque committed Jul 29, 2024
1 parent b9a0805 commit 6bdd47d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/tls"
"os"
"strconv"
"strings"

"connectrpc.com/connect"
"github.com/bufbuild/httplb"
Expand Down Expand Up @@ -86,6 +87,9 @@ func (conf *clientConfig) getClient() (client perseusapiconnect.PerseusServiceCl
MinVersion: tls.VersionTLS13,
}
opts = append(opts, httplb.WithTLSConfig(&tlsc, 0))
} else if strings.HasPrefix(conf.serverAddr, "http:") {
// switch to H2C if TLS is disabled since we're using gRPC over Connect
conf.serverAddr = "h2c" + conf.serverAddr[4:]
}

// we include WithGRPC() so that the CLI can hit an existing gRPC-based server instance
Expand Down

0 comments on commit 6bdd47d

Please sign in to comment.