github.com/rigado/snapd@v2.42.5-go-mod+incompatible/httputil/transport17.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  // +build go1.7
     4  
     5  /*
     6   * Copyright (C) 2017 Canonical Ltd
     7   *
     8   * This program is free software: you can redistribute it and/or modify
     9   * it under the terms of the GNU General Public License version 3 as
    10   * published by the Free Software Foundation.
    11   *
    12   * This program is distributed in the hope that it will be useful,
    13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15   * GNU General Public License for more details.
    16   *
    17   * You should have received a copy of the GNU General Public License
    18   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19   *
    20   */
    21  
    22  package httputil
    23  
    24  import (
    25  	"net/http"
    26  	"time"
    27  )
    28  
    29  var origDefaultTransport *http.Transport = http.DefaultTransport.(*http.Transport)
    30  
    31  // newDefaultTransport makes a fresh modifiable instance of Transport
    32  // with the same parameters as http.DefaultTransport.
    33  func newDefaultTransport() *http.Transport {
    34  	// based on https://github.com/golang/go/blob/release-branch.go1.7/src/net/http/transport.go#L38
    35  	return &http.Transport{
    36  		Proxy:                 http.ProxyFromEnvironment,
    37  		DialContext:           origDefaultTransport.DialContext,
    38  		MaxIdleConns:          100,
    39  		IdleConnTimeout:       90 * time.Second,
    40  		TLSHandshakeTimeout:   10 * time.Second,
    41  		ExpectContinueTimeout: 1 * time.Second,
    42  	}
    43  }