not_go17.go 2.6 KB

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