download

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package download handles the fetching of remote files.

Index

Constants

View Source
const (
	// UserAgent is the value of User-Agent request HEADER
	// that that lets servers identify this application.
	UserAgent = "defacto2 cli"
	// RFC5322 is a HTTP-date value.
	RFC5322 = "Mon, 2 Jan 2006 15:04:05 MST"
)

Variables

This section is empty.

Functions

func CheckTime

func CheckTime(t time.Duration) time.Duration

CheckTime creates a valid time duration for use with http.Client.Timeout. t can be 0 or a number of seconds.

func Get

func Get(name, url string) (http.Header, error)

Get downloads the url and saves it as the named file.

func Ping

func Ping(url string) (*http.Response, error)

Ping connects to a URL and returns its HTTP status code and status text.

func Silent

func Silent(name, url string) (http.Header, error)

Silent quietly downloads the URL and saves it to the named file. Not in use.

func StatusColor

func StatusColor(code int, status string) string

StatusColor colours the HTTP status based on its severity.

Types

type Request

type Request struct {
	Link       string        // URL to request.
	Timeout    time.Duration // Timeout duration (5 * time.Second).
	Read       []byte        // HTTP body data received.
	StatusCode int           // HTTP statuscode received.
	Status     string        // HTTP status received.
}

Request a HTTP download.

func (*Request) Body

func (r *Request) Body() error

Body fetches a HTTP link and returns its data and the status code.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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