Skip to content

Commit

Permalink
http3: use updated API (SetQUICHeader, QUICConfig) (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 24, 2024
1 parent 8ed005b commit cfe0ee8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions content/docs/http3/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package provides a `http.RoundTripper` implementation that can be used on t
```go
&http3.RoundTripper{
TLSClientConfig: &tls.Config{}, // set a TLS client config, if desired
QuicConfig: &quic.Config{}, // QUIC connection options
QUICConfig: &quic.Config{}, // QUIC connection options
}
defer roundTripper.Close()
client := &http.Client{
Expand All @@ -24,7 +24,7 @@ To use a custom `quic.Transport`, the function used to dial new QUIC connections
tr := quic.Transport{}
roundTripper := &http3.RoundTripper{
TLSClientConfig: &tls.Config{}, // set a TLS client config, if desired
QuicConfig: &quic.Config{}, // QUIC connection options
QUICConfig: &quic.Config{}, // QUIC connection options
Dial: func(ctx context.Context, addr string, tlsConf *tls.Config, quicConf *quic.Config) (quic.EarlyConnection, error) {
a, err := net.ResolveUDPAddr("udp", addr)
if err != nil {
Expand Down Expand Up @@ -59,7 +59,7 @@ rt := &http3.RoundTripper{
TLSClientConfig: &tls.Config{
ClientSessionCache: tls.NewLRUClientSessionCache(100),
},
QuicConfig: &quic.Config{
QUICConfig: &quic.Config{
Allow0RTT: true,
},
}
Expand Down
8 changes: 4 additions & 4 deletions content/docs/http3/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ server := http3.Server{
Handler: mux,
Addr: "0.0.0.0:443",
TLSConfig: http3.ConfigureTLSConfig(&tls.Config{}), // use your tls.Config here
QuicConfig: &quic.Config{},
QUICConfig: &quic.Config{},
}
err := server.ListenAndServe()
```
Expand Down Expand Up @@ -73,7 +73,7 @@ var handler http.Handler = http.NewServeMux()
// ... add HTTP handlers ...
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.ProtoMajor < 3 {
err := server.SetQuicHeaders(w.Header())
err := server.SetQUICHeaders(w.Header())
// ... handle error ...
}
handler.ServeHTTP(w, r)
Expand All @@ -85,11 +85,11 @@ handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
If the HTTP/3 server is located behind an L4 reverse proxy, it might be listening on a different UDP port than the port that is exposed to the internet. To accomodate for this common scenario, the external port can be configured using the `Port` field of the `http3.Server`:
```go
server := http3.Server{
Port: 443, // SetQuicHeaders will now generate the Alt-Svc header for port 443
Port: 443, // SetQUICHeaders will now generate the Alt-Svc header for port 443
}
```

More complex scenarios can be handled by manually setting the Alt-Svc header field, or by overwriting the value added by `SetQuicHeaders`.
More complex scenarios can be handled by manually setting the Alt-Svc header field, or by overwriting the value added by `SetQUICHeaders`.

## 0-RTT

Expand Down

0 comments on commit cfe0ee8

Please sign in to comment.