• Clayton Coleman's avatar
    Allow client.Config to be used for HTTP2 and WebSocket connections · d072232d
    Clayton Coleman authored
    client.Config describes how to make a client connection to a server
    for HTTP traffic, but for connection upgrade scenarios cannot be
    used because the underlying http.Transport object can't allow the
    connection to be hijacked. Reorganize the TLS and connection wrapper
    methods so that a sophisticated client can do:
    
        cfg := &client.Config{...} // from somewhere
        tlsConfig, _ := client.TLSConfigFor(cfg)
        _ := conn.Dial(...)
        rt := MyRoundTripper() // some func that implements grabbing requests
        wrapper, _ := client.HTTPWrappersFor(cfg)
        req := &http.Request{}
        req.Header.Set("Connection-Upgrade", ...)
        _, := wrapper.RoundTrip(req)
        // rt has been invoked with a fully formed Req with auth
        rt.Req.Write(conn)
        // read response for upgrade
    
    It would be good to have utility function that does more of this,
    but mostly enabling the HTTP2/SPDY client exec function right now.
    d072232d
transport_test.go 1.97 KB