utilsHttp

package
v0.0.0-...-7ec6a99 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 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"

	HeaderKeyOfRequestCookies     = "Cookie"
	HeaderKeyOfRequestReferer     = "Referer"
	HeaderKeyOfRequestContentType = "Content-Type"
	HeaderKeyOfRequestUserAgent   = "UserAgent"
	DefaultXffKeyword             = "X-Forwarded-For"
	DefaultXfhKeyword             = "X-Forwarded-Host"
	DefaultXfpKeyword             = "X-Forwarded-Proto"
)
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 GET

func GET(reqInfo *HTTPRequest)

func POST

func POST(reqInfo *HTTPRequest)

func StatusErrorMsg

func StatusErrorMsg(errcode int) string

func WGetBytes

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

Types

type HTTPRequest

type HTTPRequest struct {
	URL            string              // The URL we just crawled
	UserAgent      string              //指定请求的UserAgent信息
	ContentType    string              // Our content-type
	StatusCode     int                 // HTTP code,错误时为-1
	RequestBody    []byte              // The actual page content.
	Result         []byte              //请求结果
	InnerErr       error               // The Error Message
	ContentLength  int64               //返回的数据长度
	ResponseHeader map[string][]string //HTTP请求响应的Header
	HeaderCookies  string              //设置cookies
	HeaderReferer  string              //设置引用
}

HTTPRequest 请求结构

type URLInfo

type URLInfo 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) (URLInfo, error)

Jump to

Keyboard shortcuts

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