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 ¶
var ErrHeaderMissing = errors.NewStringError(`header unavailable`)
var ErrNonHijackableWriter = errors.NewStringError("failed to acquire raw client connection: writer is not hijackable")
ErrNonHijackableWriter is returned when the connection cannot be hijacked.
var ErrStatusCode = errors.NewStringError("status code error")
Functions ¶
func DownloadFromURL ¶
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 ¶
DownloadToFilePath downloads content from the given URL into the specified file name. In case of failure to download, the file is removed.
func HijackConnection ¶
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.