]>
Commit | Line | Data |
---|---|---|
15c0b25d AP |
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 | ||
7 | package http2 | |
8 | ||
9 | import ( | |
10 | "crypto/tls" | |
11 | "net" | |
12 | "net/http" | |
13 | "time" | |
14 | ) | |
15 | ||
16 | type contextContext interface { | |
17 | Done() <-chan struct{} | |
18 | Err() error | |
19 | } | |
20 | ||
21 | type fakeContext struct{} | |
22 | ||
23 | func (fakeContext) Done() <-chan struct{} { return nil } | |
24 | func (fakeContext) Err() error { panic("should not be called") } | |
25 | ||
26 | func reqContext(r *http.Request) fakeContext { | |
27 | return fakeContext{} | |
28 | } | |
29 | ||
30 | func setResponseUncompressed(res *http.Response) { | |
31 | // Nothing. | |
32 | } | |
33 | ||
34 | type clientTrace struct{} | |
35 | ||
36 | func requestTrace(*http.Request) *clientTrace { return nil } | |
37 | func traceGotConn(*http.Request, *ClientConn) {} | |
38 | func traceFirstResponseByte(*clientTrace) {} | |
39 | func traceWroteHeaders(*clientTrace) {} | |
40 | func traceWroteRequest(*clientTrace, error) {} | |
41 | func traceGot100Continue(trace *clientTrace) {} | |
42 | func traceWait100Continue(trace *clientTrace) {} | |
43 | ||
44 | func nop() {} | |
45 | ||
46 | func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { | |
47 | return nil, nop | |
48 | } | |
49 | ||
50 | func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { | |
51 | return ctx, nop | |
52 | } | |
53 | ||
54 | func 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: | |
59 | func 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 | ||
83 | func (cc *ClientConn) Ping(ctx contextContext) error { | |
84 | return cc.ping(ctx) | |
85 | } | |
86 | ||
87 | func (t *Transport) idleConnTimeout() time.Duration { return 0 } |