http

package
v0.0.0-...-89d9e6b Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: GPL-3.0, LGPL-3.0 Imports: 7 Imported by: 3

Documentation

Overview

Package http contains utilities for the net/http package. TODO DownloadToFilePathAtomic as DownloadToFilePath variant that only replaces the original content once a download is completed successfully. (check github.com/google/renameio)

Index

Constants

This section is empty.

Variables

View Source
var ErrHeaderMissing = errors.NewStringError(`header unavailable`)
View Source
var ErrNonHijackableWriter = errors.NewStringError("failed to acquire raw client connection: writer is not hijackable")

ErrNonHijackableWriter is returned when the connection cannot be hijacked.

View Source
var ErrStatusCode = errors.NewStringError("status code error")

Functions

func DownloadFromURL

func DownloadFromURL(dst io.Writer, url string) (int, error)

DownloadFromURL downloads content from the specified URL and immediately writes it to the destination. In case an unexpected http status code is received, an error is returned containing that status code.

func DownloadToFilePath

func DownloadToFilePath(fileName, URL string) (int, error)

DownloadToFilePath downloads content from the given URL into the specified file name. In case of failure to download, the file is removed.

func ExtractResponseHeaderDate

func ExtractResponseHeaderDate(resp *http.Response) (time.Time, error)

func HijackConnection

func HijackConnection(resp http.ResponseWriter) (io.Reader, net.Conn, error)

HijackConnection acquires the underlying connection by inspecting the ResponseWriter provided. One may use the returned io.ReadWriter to perform communication operations. The net.Conn instance is provided for low-level connection maintenance. The user must close net.Conn!

Types

This section is empty.

Jump to

Keyboard shortcuts

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