OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Bridge package to expose http internals to tests in the http_test | 5 // Bridge package to expose http internals to tests in the http_test |
6 // package. | 6 // package. |
7 | 7 |
8 package http | 8 package http |
9 | 9 |
10 import ( | 10 import ( |
(...skipping 30 matching lines...) Expand all Loading... |
41 if t.idleConn == nil { | 41 if t.idleConn == nil { |
42 return 0 | 42 return 0 |
43 } | 43 } |
44 conns, ok := t.idleConn[cacheKey] | 44 conns, ok := t.idleConn[cacheKey] |
45 if !ok { | 45 if !ok { |
46 return 0 | 46 return 0 |
47 } | 47 } |
48 return len(conns) | 48 return len(conns) |
49 } | 49 } |
50 | 50 |
| 51 func (t *Transport) IdleConnChMapSizeForTesting() int { |
| 52 t.idleMu.Lock() |
| 53 defer t.idleMu.Unlock() |
| 54 return len(t.idleConnCh) |
| 55 } |
| 56 |
51 func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler { | 57 func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler { |
52 f := func() <-chan time.Time { | 58 f := func() <-chan time.Time { |
53 return ch | 59 return ch |
54 } | 60 } |
55 return &timeoutHandler{handler, f, ""} | 61 return &timeoutHandler{handler, f, ""} |
56 } | 62 } |
57 | 63 |
58 var DefaultUserAgent = defaultUserAgent | 64 var DefaultUserAgent = defaultUserAgent |
OLD | NEW |