request

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
View Source
const CONTENT_TYPE_JSON = "application/json"
View Source
const HTTP_CODE_OK = 200
View Source
const HTTP_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
View Source
const PROTO_HTTP = "http"
View Source
const PROTO_HTTPS = "https"
View Source
const PROTO_SOCKS4 = "socks4"
View Source
const PROTO_SOCKS4A = "socks4a"
View Source
const PROTO_SOCKS5 = "socks5"
View Source
const PROTO_SS = "ss"

Variables

View Source
var DefaultTimeout = time.Second * 5

protocols

Functions

func GetReqData

func GetReqData(d map[string]string) string

* format query params

func SetTimeout added in v1.2.1

func SetTimeout(t time.Duration)

Types

type DataType added in v1.2.2

type DataType string
const DEFAULT DataType = ""
const FORM DataType = "form"
const JSON DataType = "json"

type HeaderDto added in v1.2.0

type HeaderDto struct {
	Referer                 string
	UserAgent               string
	Host                    string
	UpgradeInsecureRequests string
	Accept                  string
	AcceptEncoding          string
	AcceptLanguage          string
	SecFetchDest            string
	SecFetchMode            string
	XRequestedWith          string
	ContentType             string
	Other                   map[string]string
}

type HttpResultDto

type HttpResultDto struct {
	Body          string
	HttpCode      int
	ContentLength int64
	Header        map[string][]string
	Cookies       map[string]string
}

func Get added in v1.2.0

func Get(requestUrl string, options *Options) (*HttpResultDto, error)

Get with options

func NewHttpResultDto

func NewHttpResultDto() *HttpResultDto

func Post added in v1.2.0

func Post(requestUrl string, options *Options) (*HttpResultDto, error)

Post Post with options

func SimpleGet added in v1.2.2

func SimpleGet(requestUrl string) (*HttpResultDto, error)

SimpleGet Simple Get

func SimplePost added in v1.2.2

func SimplePost(requestUrl string, data map[string]string) (*HttpResultDto, error)

SimplePost Post

func (HttpResultDto) String

func (s HttpResultDto) String() string

type Options added in v1.2.2

type Options struct {
	Header   *HeaderDto
	Cookie   map[string]string
	Proxy    *ProxyDto
	Timeout  time.Duration
	Data     map[string]string
	Query    map[string]string
	JsonData interface{}
	DataType DataType
}

func NewOptions added in v1.2.2

func NewOptions() *Options

func (*Options) WithCookie added in v1.2.2

func (o *Options) WithCookie(cookie map[string]string) *Options

func (*Options) WithData added in v1.2.2

func (o *Options) WithData(data map[string]string) *Options

func (*Options) WithDataType added in v1.2.2

func (o *Options) WithDataType(t DataType) *Options

func (*Options) WithHeader added in v1.2.2

func (o *Options) WithHeader(header *HeaderDto) *Options

func (*Options) WithJsonData added in v1.2.2

func (o *Options) WithJsonData(data interface{}) *Options

func (*Options) WithProxy added in v1.2.2

func (o *Options) WithProxy(proxy *ProxyDto) *Options

func (*Options) WithQuery added in v1.2.3

func (o *Options) WithQuery(query map[string]string) *Options

func (*Options) WithTimeout added in v1.2.2

func (o *Options) WithTimeout(timeout time.Duration) *Options

type ProxyDto added in v1.2.0

type ProxyDto struct {
	Host     string
	Port     string
	Proto    string
	User     string
	Password string
}

Jump to

Keyboard shortcuts

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