go18.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2015 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.8
  5. package http2
  6. import (
  7. "crypto/tls"
  8. "io"
  9. "net/http"
  10. )
  11. func cloneTLSConfig(c *tls.Config) *tls.Config {
  12. c2 := c.Clone()
  13. c2.GetClientCertificate = c.GetClientCertificate // golang.org/issue/19264
  14. return c2
  15. }
  16. var _ http.Pusher = (*responseWriter)(nil)
  17. // Push implements http.Pusher.
  18. func (w *responseWriter) Push(target string, opts *http.PushOptions) error {
  19. internalOpts := pushOptions{}
  20. if opts != nil {
  21. internalOpts.Method = opts.Method
  22. internalOpts.Header = opts.Header
  23. }
  24. return w.push(target, internalOpts)
  25. }
  26. func configureServer18(h1 *http.Server, h2 *Server) error {
  27. if h2.IdleTimeout == 0 {
  28. if h1.IdleTimeout != 0 {
  29. h2.IdleTimeout = h1.IdleTimeout
  30. } else {
  31. h2.IdleTimeout = h1.ReadTimeout
  32. }
  33. }
  34. return nil
  35. }
  36. func shouldLogPanic(panicValue interface{}) bool {
  37. return panicValue != nil && panicValue != http.ErrAbortHandler
  38. }
  39. func reqGetBody(req *http.Request) func() (io.ReadCloser, error) {
  40. return req.GetBody
  41. }
  42. func reqBodyIsNoBody(body io.ReadCloser) bool {
  43. return body == http.NoBody
  44. }