blob: 7ffb25046a05a4f66187480cca18f1c0c544b04c [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// 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 "errors"
12 "net"
13 "net/http"
14 "time"
15)
16
17type contextContext interface {
18 Done() <-chan struct{}
19 Err() error
20}
21
22var errCanceled = errors.New("canceled")
23
24type fakeContext struct{}
25
26func (fakeContext) Done() <-chan struct{} { return nil }
27func (fakeContext) Err() error { panic("should not be called") }
28
29func reqContext(r *http.Request) fakeContext {
30 return fakeContext{}
31}
32
33func setResponseUncompressed(res *http.Response) {
34 // Nothing.
35}
36
37type clientTrace struct{}
38
39func requestTrace(*http.Request) *clientTrace { return nil }
40func traceGetConn(*http.Request, string) {}
41func traceGotConn(*http.Request, *ClientConn) {}
42func traceFirstResponseByte(*clientTrace) {}
43func traceWroteHeaders(*clientTrace) {}
44func traceWroteRequest(*clientTrace, error) {}
45func traceGot100Continue(trace *clientTrace) {}
46func traceWait100Continue(trace *clientTrace) {}
47
48func nop() {}
49
50func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) {
51 return nil, nop
52}
53
54func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) {
55 return ctx, nop
56}
57
58func requestWithContext(req *http.Request, ctx contextContext) *http.Request {
59 return req
60}
61
62// temporary copy of Go 1.6's private tls.Config.clone:
63func cloneTLSConfig(c *tls.Config) *tls.Config {
64 return &tls.Config{
65 Rand: c.Rand,
66 Time: c.Time,
67 Certificates: c.Certificates,
68 NameToCertificate: c.NameToCertificate,
69 GetCertificate: c.GetCertificate,
70 RootCAs: c.RootCAs,
71 NextProtos: c.NextProtos,
72 ServerName: c.ServerName,
73 ClientAuth: c.ClientAuth,
74 ClientCAs: c.ClientCAs,
75 InsecureSkipVerify: c.InsecureSkipVerify,
76 CipherSuites: c.CipherSuites,
77 PreferServerCipherSuites: c.PreferServerCipherSuites,
78 SessionTicketsDisabled: c.SessionTicketsDisabled,
79 SessionTicketKey: c.SessionTicketKey,
80 ClientSessionCache: c.ClientSessionCache,
81 MinVersion: c.MinVersion,
82 MaxVersion: c.MaxVersion,
83 CurvePreferences: c.CurvePreferences,
84 }
85}
86
87func (cc *ClientConn) Ping(ctx contextContext) error {
88 return cc.ping(ctx)
89}
90
91func (cc *ClientConn) Shutdown(ctx contextContext) error {
92 return cc.shutdown(ctx)
93}
94
95func (t *Transport) idleConnTimeout() time.Duration { return 0 }