Skip to content

Commit

Permalink
Merge pull request #60 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 3.1.3
  • Loading branch information
andyone authored Jul 26, 2016
2 parents d513de6 + 352ae0e commit 1004a47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

#### v3.1.3

* `[req]` `RequestTimeout` set to 0 (_disabled_) by default

#### v3.1.2

* `[terminal]` Fixed bug with source name file conventions
Expand Down
13 changes: 9 additions & 4 deletions req/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var (
DialTimeout = 10.0

// RequestTimeout is request timeout in seconds
RequestTimeout = 5.0
RequestTimeout = 0.0

// Dialer default dialer struct
Dialer *net.Dialer
Expand Down Expand Up @@ -240,8 +240,10 @@ func (e RequestError) Error() string {

func initTransport() {
if Dialer == nil {
Dialer = &net.Dialer{
Timeout: time.Duration(DialTimeout * float64(time.Second)),
Dialer = &net.Dialer{}

if DialTimeout > 0 {
Dialer.Timeout = time.Duration(DialTimeout * float64(time.Second))
}
}

Expand All @@ -255,7 +257,10 @@ func initTransport() {
if Client == nil {
Client = &http.Client{
Transport: Transport,
Timeout: time.Duration(RequestTimeout * float64(time.Second)),
}

if RequestTimeout > 0 {
Client.Timeout = time.Duration(RequestTimeout * float64(time.Second))
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions req/req_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func (s *ReqSuite) SetUpSuite(c *C) {

go runHTTPServer(s, c)

DialTimeout = 60.0
RequestTimeout = 60.0

time.Sleep(time.Second)
}

Expand Down

0 comments on commit 1004a47

Please sign in to comment.