forked from dropbox/godropbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pool.go
58 lines (44 loc) · 1.4 KB
/
pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package http2
import (
"net"
"net/http"
"net/url"
"time"
"github.com/dropbox/godropbox/errors"
)
// A generic interface for HTTP connection pools
type Pool interface {
// Similar interface as net/http.Client.Do()
// Most important note is that: Callers should close resp.Body
// when done reading from it. If resp.Body is not closed, the
// Client's underlying RoundTripper (typically Transport) may not
// be able to re-use a persistent TCP connection to the server
// for a subsequent "keep-alive" request.
Do(*http.Request) (*http.Response, error)
// Returns http.Client to perform http requests with, preferable
// to just use Do() function instead of this.
Get() (*http.Client, error)
// Closes underlying connection pool.
Close()
}
type ConnectionParams struct {
// Number of idle HTTP clients we allow to remain in the pool
MaxIdle int
// Use SSL transport?
UseSSL bool
// Skip verification of server SSL certificates?
SkipVerifySSL bool
// Timeout for connection (includes DNS resolution)
ConnectTimeout time.Duration
// Timeout for waiting for an HTTP response header
ResponseTimeout time.Duration
// Host header to use instead of address.
HostHeader *string
// Dial function to use instead of the default
Dial func(network, addr string) (net.Conn, error)
// Function to determine proxy
Proxy func(*http.Request) (*url.URL, error)
}
type DialError struct {
errors.DropboxError
}