models

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MethodNames = []string{http.MethodGet, http.MethodPost, http.MethodOptions, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodDelete, http.MethodConnect, http.MethodTrace}

HTTP的所有请求方法

View Source
var PermanentRedirectStatusCodes = []int{
	http.StatusMovedPermanently,
	http.StatusPermanentRedirect,
}
View Source
var RedirectStatusCodes = []int{
	http.StatusMovedPermanently,
	http.StatusFound,
	http.StatusSeeOther,
	http.StatusTemporaryRedirect,
	http.StatusPermanentRedirect,
}

Functions

This section is empty.

Types

type PrepareRequest

type PrepareRequest struct {
	Method  string
	Url     string
	Headers *http.Header
	Cookies *cookiejar.Jar
	Body    io.Reader
}

PrepareRequest结构体

func NewPrepareRequest

func NewPrepareRequest() *PrepareRequest

func (*PrepareRequest) Prepare

func (pr *PrepareRequest) Prepare(method, url string, params *url.Params, headers *http.Header, cookies *cookiejar.Jar, data *url.Values, files *url.Files, json map[string]interface{}, body string, auth []string) error

预处理所有数据

func (*PrepareRequest) Prepare_auth

func (pr *PrepareRequest) Prepare_auth(auth []string, rawurl string) error

预处理auth

func (*PrepareRequest) Prepare_body

func (pr *PrepareRequest) Prepare_body(data *url.Values, files *url.Files, json map[string]interface{}, bodys string) error

预处理body

func (*PrepareRequest) Prepare_cookies

func (pr *PrepareRequest) Prepare_cookies(cookies *cookiejar.Jar)

预处理cookie

func (*PrepareRequest) Prepare_headers

func (pr *PrepareRequest) Prepare_headers(headers *http.Header) error

预处理headers

func (*PrepareRequest) Prepare_method

func (pr *PrepareRequest) Prepare_method(method string) error

预处理method

func (*PrepareRequest) Prepare_url

func (pr *PrepareRequest) Prepare_url(rawurl string, params *url.Params) error

预处理url

type Request

type Request struct {
	Method  string
	Url     string
	Params  *url.Params
	Headers *http.Header
	Cookies *cookiejar.Jar
	Data    *url.Values
	Files   *url.Files
	Body    string
	Json    map[string]interface{}
	Auth    []string
}

func (*Request) Prepare

func (req *Request) Prepare() *PrepareRequest

type Response

type Response struct {
	Url        string
	Headers    http.Header
	Cookies    []*http.Cookie
	Text       string
	Content    []byte
	Body       io.ReadCloser
	StatusCode int
	History    []*Response
	Request    *url.Request
}

Response结构体

func (Response) IsPermanentRedirect

func (res Response) IsPermanentRedirect() bool

func (Response) IsRedirect

func (res Response) IsRedirect() bool

func (*Response) Json

func (res *Response) Json() (map[string]interface{}, error)

使用自带库JSON解析

func (Response) Ok

func (res Response) Ok() bool

状态码是否合格

func (*Response) RaiseForStatus

func (res *Response) RaiseForStatus() error

状态码是否错误

func (*Response) SimpleJson

func (res *Response) SimpleJson() (*simplejson.Json, error)

使用go-simplejson解析

Jump to

Keyboard shortcuts

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