Slide 1

Slide 1 text

Go 1.6 and HTTP/2 @nathany

Slide 2

Slide 2 text

It Just Works*

Slide 3

Slide 3 text

Server err := http.ListenAndServeTLS(":443", "cert.pem", "key.pem", nil)

Slide 4

Slide 4 text

Client response, err := http.Get("https:// http2.golang.org/reqinfo")

Slide 5

Slide 5 text

Issue #14391 • http.Client doesn't support http2 by default

Slide 6

Slide 6 text

Issue #14275 • net/http: Transport's automatic http2 too aggressive

Slide 7

Slide 7 text

golang.org/x/net/http2

Slide 8

Slide 8 text

Configure Transport transport := &http.Transport{}
 err := http2.ConfigureTransport(transport)
 if err != nil {
 log.Fatal(err)
 }
 client := &http.Client{Transport: transport}
 
 response, err := client.Get("https:// http2.golang.org/reqinfo")

Slide 9

Slide 9 text

Buford github.com/RobotsAndPencils/buford

Slide 10

Slide 10 text

Custom Cert func NewClient(cert tls.Certificate) (*http.Client, error) {
 config := &tls.Config{
 Certificates: []tls.Certificate{cert},
 }
 config.BuildNameToCertificate()
 transport := &http.Transport{TLSClientConfig: config}
 
 if err := http2.ConfigureTransport(transport); err != nil {
 return nil, err
 }
 
 return &http.Client{Transport: transport}, nil
 }