http

package
v0.0.0-...-86e3db2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetMethod  = "GET"
	PostMethod = "POST"
)

Variables

This section is empty.

Functions

func ContainsCookie

func ContainsCookie(resp *Response, cookie string) bool

func GetReqBody

func GetReqBody(body map[string]string) string

func ParseReqBody

func ParseReqBody(body string) map[string]string

Types

type Request

type Request struct {
	Method  string
	Url     *UrlObj
	Body    string
	Headers map[string]string
}

type Response

type Response struct {
	Code    int
	Reason  string
	Body    []byte
	Headers map[string]string
	Cookies []*http.Cookie
}

func DoRequest

func DoRequest(req *Request) *Response

func Get

func Get(url string) *Response

type UrlObj

type UrlObj struct {
	// https://www.xxx.com:8080/admin/index.php?id=1&page=2
	Url string
	// https
	Protocol string
	// www.xxx.com
	Host string
	// 8080
	Port int
	// /admin/index.php
	Path string
	// {id:1,page:2}
	Params map[string]string
}

UrlObj 对URL的封装 Example: https://www.xxx.com:8080/admin/index.php?id=1&page=2

func NewUrl

func NewUrl(url string) *UrlObj

func (*UrlObj) ChangeParams

func (u *UrlObj) ChangeParams(key, value string)

func (*UrlObj) RebuildUrl

func (u *UrlObj) RebuildUrl()

Jump to

Keyboard shortcuts

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