httpClient

package
v0.0.0-...-ecdf961 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 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"
)
View Source
const (
	HeaderKeyOfResponseCookies = "Set-Cookie"

	HeaderKeyOfRequestCookies     = "Cookie"
	HeaderKeyOfRequestReferer     = "Referer"
	HeaderKeyOfRequestContentType = "Content-Type"
	HeaderKeyOfRequestUserAgent   = "UserAgent"
)
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 WGET

func WGET(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