source sync 20190409
[platform/core/system/edge-orchestration.git] / vendor / github.com / miekg / dns / vendor / golang.org / x / net / http2 / not_go17.go
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         "errors"
12         "net"
13         "net/http"
14         "time"
15 )
16
17 type contextContext interface {
18         Done() <-chan struct{}
19         Err() error
20 }
21
22 var errCanceled = errors.New("canceled")
23
24 type fakeContext struct{}
25
26 func (fakeContext) Done() <-chan struct{} { return nil }
27 func (fakeContext) Err() error            { panic("should not be called") }
28
29 func reqContext(r *http.Request) fakeContext {
30         return fakeContext{}
31 }
32
33 func setResponseUncompressed(res *http.Response) {
34         // Nothing.
35 }
36
37 type clientTrace struct{}
38
39 func requestTrace(*http.Request) *clientTrace { return nil }
40 func traceGetConn(*http.Request, string)      {}
41 func traceGotConn(*http.Request, *ClientConn) {}
42 func traceFirstResponseByte(*clientTrace)     {}
43 func traceWroteHeaders(*clientTrace)          {}
44 func traceWroteRequest(*clientTrace, error)   {}
45 func traceGot100Continue(trace *clientTrace)  {}
46 func traceWait100Continue(trace *clientTrace) {}
47
48 func nop() {}
49
50 func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) {
51         return nil, nop
52 }
53
54 func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) {
55         return ctx, nop
56 }
57
58 func 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:
63 func 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
87 func (cc *ClientConn) Ping(ctx contextContext) error {
88         return cc.ping(ctx)
89 }
90
91 func (cc *ClientConn) Shutdown(ctx contextContext) error {
92         return cc.shutdown(ctx)
93 }
94
95 func (t *Transport) idleConnTimeout() time.Duration { return 0 }