func (cs *clientStream) awaitRequestCancel(req *http.Request) {
	ctx := reqContext(req)
	if req.Cancel == nil && ctx.Done() == nil {
		return
	}
	select {
	case <-req.Cancel:
		cs.cancelStream()
		cs.bufPipe.CloseWithError(errRequestCanceled)
	case <-ctx.Done():
		cs.cancelStream()
		cs.bufPipe.CloseWithError(ctx.Err())
	case <-cs.done:
	}
}
awaitRequestCancel runs in its own goroutine and waits for the user
to cancel a RoundTrip request, its context to expire, or for the
request to be done (any way it might be removed from the cc.streams
map: peer reset, successful completion, TCP connection breakage,
etc)
package http2
import (
	"bufio"
	"bytes"
	"compress/gzip"
	"crypto/rand"
	"crypto/tls"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"math"
	"net"
	"net/http"
	"sort"
	"strconv"
	"strings"
	"sync"
	"time"
	"golang.org/x/net/http2/hpack"
	"golang.org/x/net/idna"
	"golang.org/x/net/lex/httplex"
)
const (
	transportDefaultConnFlow = 1 << 30
	transportDefaultStreamFlow = 4 << 20
	transportDefaultStreamMinRefresh = 4 << 10
	defaultUserAgent = "Go-http-client/2.0"
)
type Transport struct {
	DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error)
	TLSClientConfig *tls.Config
	ConnPool ClientConnPool
	DisableCompression bool
	AllowHTTP bool
	MaxHeaderListSize uint32
	t1 *http.Transport
	connPoolOnce  sync.Once
	connPoolOrDef ClientConnPool  
}
func (t *Transport) maxHeaderListSize() uint32 {
	if t.MaxHeaderListSize == 0 {
		return 10 << 20
	}
	if t.MaxHeaderListSize == 0xffffffff {
		return 0
	}
	return t.MaxHeaderListSize
}
func (t *Transport) disableCompression() bool {
	return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
}
var errTransportVersion = errors.New("http2: ConfigureTransport is only supported starting at Go 1.6")
func ConfigureTransport(t1 *http.Transport) error {
	_, err := configureTransport(t1)  
	return err
}
func (t *Transport) connPool() ClientConnPool {
	t.connPoolOnce.Do(t.initConnPool)
	return t.connPoolOrDef
}
func (t *Transport) initConnPool() {
	if t.ConnPool != nil {
		t.connPoolOrDef = t.ConnPool
	} else {
		t.connPoolOrDef = &clientConnPool{t: t}
	}
}
type ClientConn struct {
	t         *Transport
	tconn     net.Conn              
	tlsState  *tls.ConnectionState  
	singleUse bool                  
	readerDone chan struct{}  
	readerErr  error          
	idleTimeout time.Duration  
	idleTimer   *time.Timer
	mu              sync.Mutex  
	cond            *sync.Cond  
	flow            flow        
	inflow          flow        
	closed          bool
	wantSettingsAck bool                      
	goAway          *GoAwayFrame              
	goAwayDebug     string                    
	streams         map[uint32]*clientStream  
	nextStreamID    uint32
	pings           map[[8]byte]chan struct{}  
	bw              *bufio.Writer
	br              *bufio.Reader
	fr              *Framer
	lastActive      time.Time
	maxFrameSize         uint32
	maxConcurrentStreams uint32
	initialWindowSize    uint32
	hbuf    bytes.Buffer  
	henc    *hpack.Encoder
	freeBuf [][]byte
	wmu  sync.Mutex  
	werr error       
}
type clientStream struct {
	cc            *ClientConn
	req           *http.Request
	trace         *clientTrace  
	ID            uint32
	resc          chan resAndError
	bufPipe       pipe  
	startedWrite  bool  
	requestedGzip bool
	on100         func()  
	flow        flow   
	inflow      flow   
	bytesRemain int64  
	readErr     error  
	stopReqBody error  
	didReset    bool   
	peerReset chan struct{}  
	resetErr  error          
	done chan struct{}  
	firstByte    bool  
	pastHeaders  bool  
	pastTrailers bool  
	trailer    http.Header   
	resTrailer *http.Header  
}