ezRequest

package
v0.0.0-...-77ac295 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON        = "application/json"
	ContentTypeXLSX        = "application/xlsx"
	ContentTypeOctetStream = "application/octet-stream"
	ContentTypeUrlencoded  = "application/x-www-form-urlencoded"
	ContentTypeFormData    = "multipart/form-data"
	ContentTypeXml         = "application/xml"
	ContentTypeBinary      = "application/octet-stream"
)
View Source
const (
	HeaderKeyOfResponseCookies = "Set-Cookie"

	HeaderKeyOfRequestHost        = "Host"
	HeaderKeyOfRequestCookies     = "Cookie"
	HeaderKeyOfRequestReferer     = "Referer"
	HeaderKeyOfRequestContentType = "Content-Type"
	HeaderKeyOfRequestUserAgent   = "UserAgent"
	HeaderKeyOfRequestAcceptLang  = "Accept-Language"
	DefaultXffKeyword             = "X-Forwarded-For"
	DefaultXfhKeyword             = "X-Forwarded-Host"
	DefaultXfpKeyword             = "X-Forwarded-Proto"
	DefaultXreqKeyword            = "X-Request-ID"
)
View Source
const (
	AccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	AccessControlAllowMethods     = "Access-Control-Allow-Methods"
	AccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	AccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	AccessControlMaxAge           = "Access-Control-Max-Age"
	AccessControlExposeHeaders    = "Access-Control-Expose-Headers"
)
View Source
const (
	HTTPStatusOK = http.StatusOK
)

Variables

This section is empty.

Functions

func BuildUrl

func BuildUrl(baseURL string, params map[string]string) string

func DoGet

func DoGet(w *Request, r *Response, client *http.Client)

func DoPost

func DoPost(w *Request, r *Response, client *http.Client)

func GET

func GET(w *Request, r *Response)

func POST

func POST(w *Request, r *Response)

func StatusErrorMsg

func StatusErrorMsg(errcode int) string

func WGetBytes

func WGetBytes(uri string) ([]byte, error)

Types

type Request

type Request struct {
	Uri           string // The URL we just crawled
	UserAgent     string //指定请求的UserAgent信息
	ContentType   string // Our content-type
	ContentLength int64  //返回的数据长度
	Body          []byte // The actual page content.
	Headers       map[string]string
	RequestId     string
	Host          string
}

Request 请求结构

func NewRequest

func NewRequest() *Request

func (*Request) SetContentType

func (s *Request) SetContentType(value string)

func (*Request) SetCookies

func (s *Request) SetCookies(cookies string)

func (*Request) SetHeader

func (s *Request) SetHeader(k, v string)

func (*Request) SetHost

func (s *Request) SetHost(host string)

func (*Request) SetReferer

func (s *Request) SetReferer(refer string)

func (*Request) SetRequestId

func (s *Request) SetRequestId(id string)

func (*Request) SetUserAgent

func (s *Request) SetUserAgent(value string)

type Response

type Response struct {
	StatusCode int                 // HTTP code,错误时为-1
	Result     []byte              //请求结果
	Error      error               // The Error Message
	Headers    map[string][]string //HTTP请求响应的Header
	RemoteAddr string
}

func NewResponse

func NewResponse() *Response

type Url

type Url struct {
	Scheme   string
	Username string
	Password string
	Host     string
	Port     int
	Path     string
	Fragment string
	RawQuery map[string][]string
}

func ParseURL

func ParseURL(src string) (Url, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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