httputil

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Overview

Package httputil offers functions to read and download files via HTTP.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultTransport specifies the http.RoundTripper that is used for any network traffic, and may be replaced with a dummy implementation for unit testing.
	DefaultTransport = http.DefaultTransport
)

Functions

func DownloadBinary

func DownloadBinary(originURL, destDir, destFile string) (string, error)

DownloadBinary downloads a file from the given URL into the specified location, marks it executable and returns its full path.

func MaybeDownload

func MaybeDownload(bazeliskHome, url, filename, description, token string, merger ContentMerger) ([]byte, error)

MaybeDownload downloads a file from the given url and caches the result under bazeliskHome. It skips the download if the file already exists and is not outdated. Parameter ´description´ is only used to provide better error messages.

func ReadRemoteFile

func ReadRemoteFile(url string, token string) ([]byte, http.Header, error)

ReadRemoteFile returns the contents of the given file, using the supplied Authorization token, if set. It also returns the HTTP headers.

Types

type ContentMerger added in v1.9.0

type ContentMerger func([][]byte) ([]byte, error)

Jump to

Keyboard shortcuts

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