httpclient

package
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HdrKeyUserAgent       = "User-Agent"
	HdrKeyContentType     = "Content-Type"
	HdrValApplicationJson = "application/json"
)
View Source
const (
	Timeout = 5 * time.Second
)

Variables

View Source
var Default = &http.Client{
	Timeout: Timeout,
}
View Source
var ErrRequest = errors.New("http request error")

Functions

func DefaultUserAgent

func DefaultUserAgent() string

func Get

func Get(url string) (*http.Response, error)

Get http get

func Post

func Post(url, contentType string, body io.Reader) (*http.Response, error)

Post http post

func PostFile

func PostFile(url, formName, fileName string) (*http.Response, error)

PostFile 上传文件

func PostMultipartForm

func PostMultipartForm(url string, form *MultipartForm) (*http.Response, error)

PostMultipartForm 上传文件或其他多个字段

func SetTransport added in v0.4.8

func SetTransport(v *http.Transport)

func SetUserAgent

func SetUserAgent(v string)

func UserAgent

func UserAgent() string

Types

type MultipartForm

type MultipartForm struct {
	// contains filtered or unexported fields
}

MultipartForm 保存文件或其他字段信息

func NewMultipartForm

func NewMultipartForm() *MultipartForm

func (*MultipartForm) AddFile

func (t *MultipartForm) AddFile(name, fileName string) *MultipartForm

AddFile 保存文件信息

func (*MultipartForm) AddParam

func (t *MultipartForm) AddParam(name, value string) *MultipartForm

AddParam 保存参数信息

Jump to

Keyboard shortcuts

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