1// Copyright 2016 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5// +build !go1.7 6 7package http2 8 9import ( 10 "crypto/tls" 11 "net" 12 "net/http" 13 "time" 14) 15 16type contextContext interface { 17 Done() <-chan struct{} 18 Err() error 19} 20 21type fakeContext struct{} 22 23func (fakeContext) Done() <-chan struct{} { return nil } 24func (fakeContext) Err() error { panic("should not be called") } 25 26func reqContext(r *http.Request) fakeContext { 27 return fakeContext{} 28} 29 30func setResponseUncompressed(res *http.Response) { 31 // Nothing. 32} 33 34type clientTrace struct{} 35 36func requestTrace(*http.Request) *clientTrace { return nil } 37func traceGotConn(*http.Request, *ClientConn) {} 38func traceFirstResponseByte(*clientTrace) {} 39func traceWroteHeaders(*clientTrace) {} 40func traceWroteRequest(*clientTrace, error) {} 41func traceGot100Continue(trace *clientTrace) {} 42func traceWait100Continue(trace *clientTrace) {} 43 44func nop() {} 45 46func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { 47 return nil, nop 48} 49 50func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { 51 return ctx, nop 52} 53 54func requestWithContext(req *http.Request, ctx contextContext) *http.Request { 55 return req 56} 57 58// temporary copy of Go 1.6's private tls.Config.clone: 59func cloneTLSConfig(c *tls.Config) *tls.Config { 60 return &tls.Config{ 61 Rand: c.Rand, 62 Time: c.Time, 63 Certificates: c.Certificates, 64 NameToCertificate: c.NameToCertificate, 65 GetCertificate: c.GetCertificate, 66 RootCAs: c.RootCAs, 67 NextProtos: c.NextProtos, 68 ServerName: c.ServerName, 69 ClientAuth: c.ClientAuth, 70 ClientCAs: c.ClientCAs, 71 InsecureSkipVerify: c.InsecureSkipVerify, 72 CipherSuites: c.CipherSuites, 73 PreferServerCipherSuites: c.PreferServerCipherSuites, 74 SessionTicketsDisabled: c.SessionTicketsDisabled, 75 SessionTicketKey: c.SessionTicketKey, 76 ClientSessionCache: c.ClientSessionCache, 77 MinVersion: c.MinVersion, 78 MaxVersion: c.MaxVersion, 79 CurvePreferences: c.CurvePreferences, 80 } 81} 82 83func (cc *ClientConn) Ping(ctx contextContext) error { 84 return cc.ping(ctx) 85} 86 87func (t *Transport) idleConnTimeout() time.Duration { return 0 } 88