http

package
v1.20.14 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET             = "GET"
	POST            = "POST"
	DELETE          = "DELETE"
	PUT             = "PUT"
	PATCH           = "PATCH"
	HEAD            = "HEAD"
	OPTIONS         = "OPTIONS"
	ContentTypeJSON = "application/json"
	ContentTypeForm = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Request Http Request

func NewRequest

func NewRequest(method, urlString string) *Request

NewRequest 新的Request指针

func (*Request) AddCookie added in v1.20.2

func (m *Request) AddCookie(cookie *http.Cookie)

AddCookie 添加COOKIE

func (*Request) AddFile added in v1.20.2

func (m *Request) AddFile(name, filename, path string)

AddFile 增加文件

func (*Request) AddHeader added in v1.20.2

func (m *Request) AddHeader(key, value string)

AddHeader 增加Header头

func (*Request) AddParam added in v1.20.2

func (m *Request) AddParam(key, value string)

AddParam 增加Get请求参数

func (*Request) Exec added in v1.20.2

func (m *Request) Exec() *Response

Exec 发送HTTP请求

func (*Request) RemoveFile added in v1.20.2

func (m *Request) RemoveFile()

RemoveFile 移除文件

func (*Request) SetBody added in v1.20.2

func (m *Request) SetBody(body io.Reader)

SetBody 设定POST内容

func (*Request) SetContentType added in v1.20.2

func (m *Request) SetContentType(contentType string)

SetContentType 设定Content-Type

func (*Request) SetHeader added in v1.20.2

func (m *Request) SetHeader(key, value string)

SetHeader 设定Header头

func (*Request) SetHeaders added in v1.20.2

func (m *Request) SetHeaders(header http.Header)

SetHeaders 设定Header头

func (*Request) SetParam added in v1.20.2

func (m *Request) SetParam(key, value string)

SetParam 设定Get请求参数

func (*Request) SetParams added in v1.20.2

func (m *Request) SetParams(params cmap.CMap)

SetParams 设定Get请求参数

func (*Request) SetStructParams added in v1.20.2

func (m *Request) SetStructParams(v interface{})

SetStructParams struct to Params

type Response added in v1.20.2

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

Response Http请求返回内容

func (*Response) Bytes added in v1.20.2

func (m *Response) Bytes() ([]byte, error)

Bytes 返回byte数据

func (*Response) Error added in v1.20.2

func (m *Response) Error() error

func (*Response) MustBytes added in v1.20.2

func (m *Response) MustBytes() []byte

MustBytes 返回byte数据

func (*Response) MustString added in v1.20.2

func (m *Response) MustString() string

MustString 返回string数据

func (*Response) String added in v1.20.2

func (m *Response) String() (string, error)

String 返回string数据

func (*Response) Unmarshal added in v1.20.2

func (m *Response) Unmarshal(v interface{}) error

Unmarshal 返回反序列化JSON

Jump to

Keyboard shortcuts

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