httputil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// HeaderContentType the Content-Type http header
	HeaderContentType = "Content-Type"
)

Variables

This section is empty.

Functions

func NewTLSConfig

func NewTLSConfig(insecureSkipVerify bool, certFile string) (*tls.Config, error)

NewTLSConfig create a tls config

Types

type HttpClient

type HttpClient interface {
	// HttpGet get http resource
	HttpGet(url string) (resp *http.Response, err error)
	// HttpGetWithCookie get http resource with cookies
	HttpGetWithCookie(url string, header http.Header, cookies ...*http.Cookie) (resp *http.Response, err error)
	// HttpPost send a post request with form data
	HttpPost(url string, data url.Values) (resp *http.Response, err error)
	// HttpPostWithCookie send a post request with form data and cookies
	HttpPostWithCookie(url string, data url.Values, cookies ...*http.Cookie) (resp *http.Response, err error)
	// HttpPostFileChunkWithCookie send a post request with form data, a file chunk and cookies
	HttpPostFileChunkWithCookie(url string, fieldName string, fileName string, data url.Values, chunk []byte, cookies ...*http.Cookie) (resp *http.Response, err error)
	// HttpPostWithoutRedirect send a post request with form data and not auto redirect
	HttpPostWithoutRedirect(url string, data url.Values) (resp *http.Response, err error)
	// Download if the local file does not exist and the alwaysDownload is false, downloads the remote file to local path
	Download(path, url string, alwaysDownload bool) error
}

HttpClient an HTTP client component that supports chunked file uploads using the POST method

func NewHttpClient

func NewHttpClient(insecureSkipVerify bool, certFile string, enableHTTP3 bool) (HttpClient, error)

NewHttpClient create a http client

Jump to

Keyboard shortcuts

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