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