go18.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 { return c.Clone() }
  12. var _ http.Pusher = (*responseWriter)(nil)
  13. // Push implements http.Pusher.
  14. func (w *responseWriter) Push(target string, opts *http.PushOptions) error {
  15. internalOpts := pushOptions{}
  16. if opts != nil {
  17. internalOpts.Method = opts.Method
  18. internalOpts.Header = opts.Header
  19. }
  20. return w.push(target, internalOpts)
  21. }
  22. func configureServer18(h1 *http.Server, h2 *Server) error {
  23. if h2.IdleTimeout == 0 {
  24. if h1.IdleTimeout != 0 {
  25. h2.IdleTimeout = h1.IdleTimeout
  26. } else {
  27. h2.IdleTimeout = h1.ReadTimeout
  28. }
  29. }
  30. return nil
  31. }
  32. func shouldLogPanic(panicValue interface{}) bool {
  33. return panicValue != nil && panicValue != http.ErrAbortHandler
  34. }
  35. func reqGetBody(req *http.Request) func() (io.ReadCloser, error) {
  36. return req.GetBody
  37. }
  38. func reqBodyIsNoBody(body io.ReadCloser) bool {
  39. return body == http.NoBody
  40. }