Maximum redirection option added. Performance improvement on exports. Duplicate requests only checked on GET requests.

This commit is contained in:
Musab Gültekin
2019-07-01 15:44:28 +03:00
parent 80f3500a69
commit c0dd0393e6
6 changed files with 71 additions and 16 deletions

View File

@ -48,7 +48,7 @@ func NewGeziyor(opt *Options) *Geziyor {
geziyor := &Geziyor{
Client: client.NewClient(),
Opt: opt,
Exports: make(chan interface{}),
Exports: make(chan interface{}, 1),
requestMiddlewares: []RequestMiddleware{
allowedDomainsMiddleware,
duplicateRequestsMiddleware,
@ -81,6 +81,9 @@ func NewGeziyor(opt *Options) *Geziyor {
if !opt.CookiesDisabled {
geziyor.Client.Jar, _ = cookiejar.New(nil)
}
if opt.MaxRedirect != 0 {
geziyor.Client.CheckRedirect = client.NewRedirectionHandler(opt.MaxRedirect)
}
if opt.ConcurrentRequests != 0 {
geziyor.semGlobal = make(chan struct{}, opt.ConcurrentRequests)
}