OSDN Git Service

net/http: delete temporary files.
[pf3gnuchains/gcc-fork.git] / libgo / go / net / http / export_test.go
1 // Copyright 2011 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 // Bridge package to expose http internals to tests in the http_test
6 // package.
7
8 package http
9
10 func (t *Transport) IdleConnKeysForTesting() (keys []string) {
11         keys = make([]string, 0)
12         t.lk.Lock()
13         defer t.lk.Unlock()
14         if t.idleConn == nil {
15                 return
16         }
17         for key := range t.idleConn {
18                 keys = append(keys, key)
19         }
20         return
21 }
22
23 func (t *Transport) IdleConnCountForTesting(cacheKey string) int {
24         t.lk.Lock()
25         defer t.lk.Unlock()
26         if t.idleConn == nil {
27                 return 0
28         }
29         conns, ok := t.idleConn[cacheKey]
30         if !ok {
31                 return 0
32         }
33         return len(conns)
34 }
35
36 func NewTestTimeoutHandler(handler Handler, ch <-chan int64) Handler {
37         f := func() <-chan int64 {
38                 return ch
39         }
40         return &timeoutHandler{handler, f, ""}
41 }