fetch

package
v3.4.5+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package fetch contains the HTTP client that just-install uses to download installers over HTTP(S). It mostly contains functions built on top of Go's HTTP client.

Index

Constants

View Source
const ConnectionPhaseTimeout = 5 * time.Second

ConnectionPhaseTimeout is the timeout used as upper bound for various phases of the connection to a remote host (i.e. establishing a TCP connection, TLS handshake, etc). This is kept as short as possible to immediately catch transient network errors.

View Source
const RequestTimeout = 30 * time.Minute

RequestTimeout is the timeout used as the upper bound for an entire HTTP request, including the time needed to download the requested file.

Variables

View Source
var Transport = &http.Transport{
	DialContext: (&net.Dialer{
		DualStack: true,
		KeepAlive: 0,
		Timeout:   ConnectionPhaseTimeout,
	}).DialContext,
	DisableKeepAlives:     true,
	ExpectContinueTimeout: ConnectionPhaseTimeout,
	IdleConnTimeout:       ConnectionPhaseTimeout,
	MaxConnsPerHost:       1,
	Proxy:                 http.ProxyFromEnvironment,
	ResponseHeaderTimeout: ConnectionPhaseTimeout,
	TLSHandshakeTimeout:   ConnectionPhaseTimeout,
}

Transport is an HTTP transport optimized to perform a sigle request to a single host, with short timeouts for various connection phases.

Functions

func NewClient

func NewClient() *http.Client

NewClient creates a new HTTP client with a default request timeout (see also `RequestTimeout`) that uses our `Transport`. Unlike Go stdlib's HTTP client, ours is to be closed and discarded after one request.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL