Skip to content
Snippets Groups Projects
Select Git revision
  • 98e2528f410908e50b4be3a2d5f6ed2b5f32bd2c
  • master default protected
  • better-queue
3 results

client.go

Blame
    • ale's avatar
      ee1a3d8e
      Improve error checking · ee1a3d8e
      ale authored
      Detect write errors (both on the database and to the WARC output) and
      abort with an error message.
      
      Also fix a bunch of harmless lint warnings.
      ee1a3d8e
      History
      Improve error checking
      ale authored
      Detect write errors (both on the database and to the WARC output) and
      abort with an error message.
      
      Also fix a bunch of harmless lint warnings.
    client.go 687 B
    package crawl
    
    import (
    	"crypto/tls"
    	"net/http"
    	"net/http/cookiejar"
    	"time"
    )
    
    var defaultClientTimeout = 60 * time.Second
    
    // DefaultClient returns a http.Client suitable for crawling: does not
    // follow redirects, accepts invalid TLS certificates, sets a
    // reasonable timeout for requests.
    var DefaultClient *http.Client
    
    func init() {
    	jar, _ := cookiejar.New(nil) // nolint
    	DefaultClient = &http.Client{
    		Timeout: defaultClientTimeout,
    		Transport: &http.Transport{
    			TLSClientConfig: &tls.Config{
    				InsecureSkipVerify: true, // nolint
    			},
    		},
    		CheckRedirect: func(req *http.Request, via []*http.Request) error {
    			return http.ErrUseLastResponse
    		},
    		Jar: jar,
    	}
    }