not_go17.go 2.2 KB

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