not_go17.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // +build !go1.7
  5. package http2
  6. import (
  7. "crypto/tls"
  8. "net"
  9. "net/http"
  10. "time"
  11. )
  12. type contextContext interface {
  13. Done() <-chan struct{}
  14. Err() error
  15. }
  16. type fakeContext struct{}
  17. func (fakeContext) Done() <-chan struct{} { return nil }
  18. func (fakeContext) Err() error { panic("should not be called") }
  19. func reqContext(r *http.Request) fakeContext {
  20. return fakeContext{}
  21. }
  22. func setResponseUncompressed(res *http.Response) {
  23. // Nothing.
  24. }
  25. type clientTrace struct{}
  26. func requestTrace(*http.Request) *clientTrace { return nil }
  27. func traceGotConn(*http.Request, *ClientConn) {}
  28. func traceFirstResponseByte(*clientTrace) {}
  29. func traceWroteHeaders(*clientTrace) {}
  30. func traceWroteRequest(*clientTrace, error) {}
  31. func traceGot100Continue(trace *clientTrace) {}
  32. func traceWait100Continue(trace *clientTrace) {}
  33. func nop() {}
  34. func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) {
  35. return nil, nop
  36. }
  37. func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) {
  38. return ctx, nop
  39. }
  40. func requestWithContext(req *http.Request, ctx contextContext) *http.Request {
  41. return req
  42. }
  43. // temporary copy of Go 1.6's private tls.Config.clone:
  44. func cloneTLSConfig(c *tls.Config) *tls.Config {
  45. return &tls.Config{
  46. Rand: c.Rand,
  47. Time: c.Time,
  48. Certificates: c.Certificates,
  49. NameToCertificate: c.NameToCertificate,
  50. GetCertificate: c.GetCertificate,
  51. RootCAs: c.RootCAs,
  52. NextProtos: c.NextProtos,
  53. ServerName: c.ServerName,
  54. ClientAuth: c.ClientAuth,
  55. ClientCAs: c.ClientCAs,
  56. InsecureSkipVerify: c.InsecureSkipVerify,
  57. CipherSuites: c.CipherSuites,
  58. PreferServerCipherSuites: c.PreferServerCipherSuites,
  59. SessionTicketsDisabled: c.SessionTicketsDisabled,
  60. SessionTicketKey: c.SessionTicketKey,
  61. ClientSessionCache: c.ClientSessionCache,
  62. MinVersion: c.MinVersion,
  63. MaxVersion: c.MaxVersion,
  64. CurvePreferences: c.CurvePreferences,
  65. }
  66. }
  67. func (cc *ClientConn) Ping(ctx contextContext) error {
  68. return cc.ping(ctx)
  69. }
  70. func (t *Transport) idleConnTimeout() time.Duration { return 0 }