network

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HttpClient = &http.Client{
	Timeout: 10 * time.Second,
}

Functions

func Fetch

func Fetch(inputURL string) (bytes []byte, err error)

Fetch fetches the response body from a given URL after validating it. If the URL scheme is "file", the file is fetched from the local filesystem. If the URL scheme is "http", "https", or "ftp", the file is fetched from the remote server. If the URL has a checksum, the file is validated against the checksum.

func FetchLocalFile

func FetchLocalFile(url *url.URL) ([]byte, error)

FetchLocalFile fetches a local file from a given URL. If the URL scheme is not "file", an error is returned. If the URL is relative, the component definition directory is prepended if set, otherwise the current working directory is prepended.

func ParseChecksum

func ParseChecksum(src string) (*url.URL, string, error)

ParseChecksum parses a URL string into a url.URL object. If the URL has a checksum, the checksum is removed from the URL and returned.

func ValidateChecksum

func ValidateChecksum(data []byte, expectedChecksum string) error

ValidateChecksum validates a given checksum against a given []bytes. Supports MD5, SHA-1, SHA-256, and SHA-512. Returns an error if the hash does not match.

Types

This section is empty.

Jump to

Keyboard shortcuts

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