Timeout support added
This commit is contained in:
parent
2e3bd18430
commit
f2fba85266
@ -40,6 +40,9 @@ func NewGeziyor(opt Options) *Geziyor {
|
||||
if opt.Cache != nil {
|
||||
geziyor.client.Transport = httpcache.NewTransport(opt.Cache)
|
||||
}
|
||||
if opt.Timeout != 0 {
|
||||
geziyor.client.Timeout = opt.Timeout
|
||||
}
|
||||
|
||||
return geziyor
|
||||
}
|
||||
@ -92,6 +95,7 @@ func (g *Geziyor) Do(req *http.Request) {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("Response error: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package geziyor
|
||||
|
||||
import (
|
||||
"github.com/fpfeng/httpcache"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Options is custom options type for Geziyor
|
||||
@ -13,6 +14,8 @@ type Options struct {
|
||||
StartURLs []string
|
||||
// ParseFunc is callback of StartURLs response.
|
||||
ParseFunc func(response *Response)
|
||||
// Timeout is global request timeout
|
||||
Timeout time.Duration
|
||||
|
||||
// Set this to enable caching responses.
|
||||
// Memory Cache: httpcache.NewMemoryCache()
|
||||
|
Loading…
x
Reference in New Issue
Block a user