Documentation
¶
Index ¶
- Constants
- Variables
- func AdjustPrintOption(s *string, r rune, flags uint32)
- func ColorStart(color uint8) string
- func ColorfulHTML(str string) string
- func ColorfulRequest(str string) string
- func ColorfulResponse(str string, isJSON bool) string
- func DecodePemBlocks(certInput string) (blocks []*pem.Block)
- func DecodePemChain(certInput string) (chain [][]byte)
- func Eval(s string) (string, error)
- func GetVar(name string) string
- func Getenv(keys ...string) string
- func HasAnyPrintOptions(flags ...uint32) bool
- func HasPrintOption(flags uint32) bool
- func HashFile(f string, h hash.Hash) ([]byte, error)
- func LinesChan(filePath string) (func() (string, error), error)
- func LoadCerts(certFiles []string) (certs []tls.Certificate, err error)
- func NewGzipReader(source io.Reader) *io.PipeReader
- func ReadLine(fns ...LineConfigFn) (string, error)
- func RemoveChars(input, cutset string) string
- func Resolve(host, dnsServer string) ([]string, error)
- func Run()
- func RunBench(b *Request, thinkerFn func())
- func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)
- func Stat(name string) (int64, bool, error)
- func TeeReadeCloser(r io.ReadCloser, w io.Writer) io.ReadCloser
- func Try[T any](a T, err error) T
- type DialContextFn
- type InfluxQueryResult
- type LineConfig
- type LineConfigFn
- type LogRedirects
- type MyConn
- type ProgressBar
- func (pb *ProgressBar) Add(add int) int
- func (pb *ProgressBar) Add64(add int64) int64
- func (pb *ProgressBar) Finish()
- func (pb *ProgressBar) Increment() int
- func (pb *ProgressBar) Set(current int)
- func (pb *ProgressBar) SetTotal(total int64)
- func (pb *ProgressBar) Start() *ProgressBar
- func (pb *ProgressBar) Update()
- func (pb *ProgressBar) Write(p []byte) (n int, err error)
- type ProgressBarReader
- type RateLimitDirection
- type RateLimitFlag
- type Request
- func (b *Request) Body(data any) *Request
- func (b *Request) BodyAndSize(body io.ReadCloser, size int64) *Request
- func (b *Request) BodyCh(data func() (string, error)) *Request
- func (b *Request) BodyFileLines(t string) bool
- func (b *Request) BodyString(s string)
- func (b *Request) BuildURL()
- func (b *Request) Bytes() ([]byte, error)
- func (b *Request) DumpBody(isdump bool) *Request
- func (b *Request) DumpRequest(dumpRequest bool) *Request
- func (b *Request) Header(key, value string) *Request
- func (b *Request) NextBody() error
- func (b *Request) Param(key, value string) *Request
- func (b *Request) PostFile(formname, filename string) *Request
- func (b *Request) Query(key, value string) *Request
- func (b *Request) RefreshBody() *Request
- func (b *Request) Reset()
- func (b *Request) Response() (*http.Response, error)
- func (b *Request) SendOut() (*http.Response, error)
- func (b *Request) SetBasicAuth(username, password string) *Request
- func (b *Request) SetCookie(cookie *http.Cookie) *Request
- func (b *Request) SetEnableCookie(enable bool) *Request
- func (b *Request) SetHost(host string) *Request
- func (b *Request) SetProtocolVersion(vers string) *Request
- func (b *Request) SetProxy(proxy func(*http.Request) (*url.URL, error)) *Request
- func (b *Request) SetTLSClientConfig(config *tls.Config) *Request
- func (b *Request) SetTimeout(connectTimeout time.Duration) *Request
- func (b *Request) SetTransport(transport http.RoundTripper) *Request
- func (b *Request) SetUserAgent(useragent string) *Request
- func (b *Request) SetupTransport()
- func (b *Request) String() (string, error)
- func (b *Request) ToFile(filename string) error
- func (b *Request) ToJSON(v any) error
- func (b *Request) ToXML(v any) error
- type Series
- type Settings
- type Valuer
Constants ¶
const ( Gray = uint8(iota + 90) Green Yellow Magenta Cyan EndColor = "\033[0m" )
const ( MaxPayloadSize = "MAX_PAYLOAD_SIZE" DefaultMaxPayloadSize = 1024 * 1024 )
const (
DefaultRefreshRate = 200 * time.Millisecond
)
const DryRequestURL = `http://dry.run.url`
Variables ¶
var Color = func(str string, color uint8) string { if hasStdoutDevice { return fmt.Sprintf("%s%s%s", ColorStart(color), str, EndColor) } return str }
var ( // ErrWrongCodeForByteRange is returned if the client sends a request // with a Range header but the server returns a 2xx or 3xx code other // than 206 Partial Content. ErrWrongCodeForByteRange = errors.New("expected HTTP 206 from byte range request") )
Functions ¶
func AdjustPrintOption ¶
func ColorStart ¶
func ColorfulHTML ¶
func ColorfulRequest ¶
func ColorfulResponse ¶
func DecodePemBlocks ¶
DecodePemBlocks 解析 PEM 字符串中的块
func DecodePemChain ¶
DecodePemChain 解析 PEM 字符串中的证书链 thanks https://gist.github.com/laher/5795578
func HasAnyPrintOptions ¶
func HasPrintOption ¶
func NewGzipReader ¶
func NewGzipReader(source io.Reader) *io.PipeReader
func ReadLine ¶
func ReadLine(fns ...LineConfigFn) (string, error)
func RemoveChars ¶
func ScanLines ¶
ScanLines is a split function for a Scanner that returns each line of text, with end-of-line marker. The returned line may be empty. The end-of-line marker is one optional carriage return followed by one mandatory newline. In regular expression notation, it is `\r?\n`. The last non-empty line of input will be returned even if it has no newline.
func TeeReadeCloser ¶
func TeeReadeCloser(r io.ReadCloser, w io.Writer) io.ReadCloser
TeeReadeCloser returns a ReadCloser that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.
Types ¶
type DialContextFn ¶
func TimeoutDialer ¶
func TimeoutDialer(cTimeout time.Duration, tlsConfig *tls.Config, debug bool, r, w *int64) DialContextFn
TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field.
type InfluxQueryResult ¶
type LineConfig ¶
type LineConfigFn ¶
type LineConfigFn func(config *LineConfig)
func WithHistoryFile ¶
func WithHistoryFile(historyFile string) LineConfigFn
func WithPrompt ¶
func WithPrompt(prompt string) LineConfigFn
func WithTrimSuffix ¶
func WithTrimSuffix(trimSuffix bool) LineConfigFn
type LogRedirects ¶
type LogRedirects struct {
http.RoundTripper
}
LogRedirects log redirect refer: Go HTTP Redirect的知识点总结 https://colobu.com/2017/04/19/go-http-redirect/
type ProgressBar ¶
type ProgressBar struct { BarStart string CurrentN string Current string Empty string BarEnd string Total int64 RefreshRate time.Duration ShowFinalTime bool ShowSpeed, ShowTimeLeft, ShowBar bool ShowPercent, ShowCounters bool // contains filtered or unexported fields }
func NewProgressBar ¶
func NewProgressBar(total int64) (pb *ProgressBar)
func (*ProgressBar) Add64 ¶
func (pb *ProgressBar) Add64(add int64) int64
func (*ProgressBar) SetTotal ¶
func (pb *ProgressBar) SetTotal(total int64)
func (*ProgressBar) Start ¶
func (pb *ProgressBar) Start() *ProgressBar
func (*ProgressBar) Update ¶
func (pb *ProgressBar) Update()
Update the current state of the progressbar
type ProgressBarReader ¶
type ProgressBarReader struct { io.ReadCloser // contains filtered or unexported fields }
type RateLimitDirection ¶
type RateLimitDirection int
const ( RateLimitBoth RateLimitDirection = iota RateLimitRequest RateLimitResponse )
type RateLimitFlag ¶
type RateLimitFlag struct { Val *uint64 Direction RateLimitDirection }
func NewRateLimitFlag ¶
func NewRateLimitFlag() *RateLimitFlag
func (*RateLimitFlag) Enabled ¶
func (i *RateLimitFlag) Enabled() bool
func (*RateLimitFlag) Float64 ¶
func (i *RateLimitFlag) Float64() float64
func (*RateLimitFlag) IsForReq ¶
func (i *RateLimitFlag) IsForReq() bool
func (*RateLimitFlag) IsForRsp ¶
func (i *RateLimitFlag) IsForRsp() bool
func (*RateLimitFlag) Set ¶
func (i *RateLimitFlag) Set(value string) (err error)
func (*RateLimitFlag) String ¶
func (i *RateLimitFlag) String() string
func (*RateLimitFlag) Type ¶
func (i *RateLimitFlag) Type() string
type Request ¶
type Request struct { Transport http.RoundTripper Req *http.Request ConnInfo httptrace.GotConnInfo Setting Settings Timeout time.Duration DryRequest bool DisableKeepAlives bool // contains filtered or unexported fields }
Request provides more useful methods for requesting one url than http.Request.
func NewRequest ¶
NewRequest return *Request with specific method
func (*Request) BodyAndSize ¶
func (b *Request) BodyAndSize(body io.ReadCloser, size int64) *Request
func (*Request) BodyFileLines ¶
func (*Request) BodyString ¶
func (*Request) DumpRequest ¶
DumpRequest sets show debug or not when executing request.
func (*Request) Param ¶
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*Request) Query ¶
Query adds query param in to request. params build query string as ?key1=value1&key2=value2...
func (*Request) RefreshBody ¶
RefreshBody 刷新 body 值,在 -n2 以上时使用
func (*Request) SetBasicAuth ¶
SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.
func (*Request) SetEnableCookie ¶
SetEnableCookie sets enable/disable cookiejar
func (*Request) SetProtocolVersion ¶
SetProtocolVersion Set the protocol version for incoming requests. Client requests always use HTTP/1.1.
func (*Request) SetProxy ¶
SetProxy Set http proxy example:
func(Req *http.Request) (*url.URL, error) { u, _ := url.ParseRequestURI("http://127.0.0.1:8118") return u, nil }
func (*Request) SetTLSClientConfig ¶
SetTLSClientConfig sets tls connection configurations if visiting https url.
func (*Request) SetTimeout ¶
SetTimeout sets connect time out and read-write time out for BeegoRequest.
func (*Request) SetTransport ¶
func (b *Request) SetTransport(transport http.RoundTripper) *Request
SetTransport Set transport to
func (*Request) SetUserAgent ¶
SetUserAgent sets User-Agent header field
func (*Request) SetupTransport ¶
func (b *Request) SetupTransport()
func (*Request) ToFile ¶
ToFile saves the body data in response to one file. it calls Response inner.