curl

package
v0.0.0-...-5870b03 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRequestTimeout = errors.New("do request time out")
View Source
var ErrStopRedirect = errors.New("not allowed auto redirect")

Functions

This section is empty.

Types

type Curl

type Curl struct {
	Url string

	Headers http.Header

	//流
	PostReader io.Reader
	//[]byte格式
	PostBytes []byte
	//string格式
	PostString string
	//key=>value格式
	PostFields       neturl.Values
	PostFieldReaders map[string]io.Reader
	//文件,key是字段名,val是文件路径
	PostFiles neturl.Values
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, method string, url string) (curls *Curl)

func NewGet

func NewGet(ctx context.Context, url string) *Curl

func NewPost

func NewPost(ctx context.Context, url string) *Curl

func (*Curl) CreateRequest

func (curls *Curl) CreateRequest() (httpRequest *http.Request, err error)

func (*Curl) Request

func (curls *Curl) Request() (rs *Response, err error)

func (*Curl) SetAutoRedirect

func (curls *Curl) SetAutoRedirect()

func (*Curl) SetContext

func (curls *Curl) SetContext(ctx context.Context)

func (*Curl) SetCookies

func (curls *Curl) SetCookies(cookies []*http.Cookie)

func (*Curl) SetHeaders

func (curls *Curl) SetHeaders(headers map[string]string)

func (*Curl) SetKeepAlive

func (curls *Curl) SetKeepAlive()

func (*Curl) SetPostBytes

func (curls *Curl) SetPostBytes(b []byte)

以字节的方式

func (*Curl) SetPostField

func (curls *Curl) SetPostField(key, value string)

以key=>value方式,以下三个都是key=>value方式,可以共同使用

func (*Curl) SetPostFieldReader

func (curls *Curl) SetPostFieldReader(key string, r io.Reader)

以流的方式

func (*Curl) SetPostFile

func (curls *Curl) SetPostFile(key, path string)

以上传文件的方式

func (*Curl) SetPostReader

func (curls *Curl) SetPostReader(r io.Reader)

以字节流的方式

func (*Curl) SetPostString

func (curls *Curl) SetPostString(s string)

以字符串的方式

func (*Curl) SetProxy

func (curls *Curl) SetProxy(proxyURL string)

func (*Curl) SetTimeout

func (curls *Curl) SetTimeout(t int)

func (*Curl) SetTimeoutMS

func (curls *Curl) SetTimeoutMS(t int)

毫秒

type Response

type Response struct {
	*http.Response
	Body io.ReadCloser
	// contains filtered or unexported fields
}

func (*Response) Close

func (response *Response) Close()

Jump to

Keyboard shortcuts

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