download

package
v1.1.30 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package download handles the fetching of remote files.

Index

Constants

View Source
const RFC5322 string = "Mon, 2 Jan 2006 15:04:05 MST"

RFC5322 is a HTTP-date value.

View Source
const UserAgent string = "defacto2 cli"

UserAgent is the value of User-Agent request HEADER that that lets servers identify this application.

Variables

This section is empty.

Functions

func LinkDownload

func LinkDownload(name, link string) (http.Header, error)

LinkDownload downloads the link and saves it as the named file.

func LinkDownloadQ

func LinkDownloadQ(name, link string) (http.Header, error)

LinkDownloadQ quietly downloads the URL and saves it to the named file. Not used.

func LinkPing

func LinkPing(link string) (*http.Response, error)

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

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 in seconds
	Read       []byte        // received HTTP body data
	StatusCode int           // received HTTP statuscode
	Status     string        // received HTTP status
}

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.

type WriteCounter

type WriteCounter struct {
	Name    string // Filename
	Total   uint64 // Expected filesize
	Written uint64 // Bytes written
}

WriteCounter totals the number of bytes written.

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Write progress counter.

Jump to

Keyboard shortcuts

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