httpfile

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisaableAutoClean

func DisaableAutoClean(f *HTTPFile)

DisaableAutoClean disable clear after Exectue

func Execute

func Execute(file *HTTPFile) string

Execute the file once

func HumanOutput

func HumanOutput(report *Report, w io.Writer)

HumanOutput is plain output of report

func JSONPathGet

func JSONPathGet(data interface{}, path string) string

JSONPathGet get a pathed value from data

func PlainOutput

func PlainOutput(report *Report, w io.Writer)

PlainOutput is plain output of report

func ReplaceVariable

func ReplaceVariable(text []byte, ve Replacer) []byte

ReplaceVariable replace variable placeholder to value

func ReplaceVariableString

func ReplaceVariableString(text string, ve Replacer) string

ReplaceVariableString replace variable placeholder to value string

Types

type Case

type Case struct {
	Name         string        // name of case
	RespCode     int           // reponse code
	RequestSize  int           // request body length
	ResponseSize int           // resoonse bytes length
	RespTime     time.Duration // response time
	// contains filtered or unexported fields
}

Case is a http request case

type HTTPFile

type HTTPFile struct {
	Variables map[string]string // variable in this file
	Cases     []*Case           // all cases
	AutoClean bool              // automatic release resource, otherwise caller should do Release after use, default is true
}

HTTPFile is a .http or .rest file parse result

func ParseBytes

func ParseBytes(content []byte, opts ...Opt) (*HTTPFile, error)

ParseBytes parse httpfile from content

func ParseFile

func ParseFile(fileName string, opts ...Opt) (*HTTPFile, error)

ParseFile parse httpfile from a file

func ParseReader

func ParseReader(r io.Reader, opts ...Opt) (*HTTPFile, error)

ParseReader parse httpfile from a reader

func (*HTTPFile) Duplicate

func (f *HTTPFile) Duplicate(useMock bool, expand bool) *HTTPFile

Duplicate this file, if mock is used, variable will be mocked

func (*HTTPFile) Execute

func (f *HTTPFile) Execute(client *fasthttp.Client, ve ...Replacer) error

Execute the httfile

func (*HTTPFile) Get

func (f *HTTPFile) Get(key string) (string, bool)

Get is required by ValueExtractor interface

func (*HTTPFile) Release

func (f *HTTPFile) Release()

Release resource

type ListReplacer

type ListReplacer []Replacer

ListReplacer is a ValueExtractor based on []ValueExtractor

func (ListReplacer) Get

func (le ListReplacer) Get(key string) (string, bool)

Get is required by ValueExtractor interface

type MapReplacer

type MapReplacer map[string]string

MapReplacer is a ValueExtractor based on map[string]string

func (MapReplacer) Get

func (me MapReplacer) Get(key string) (string, bool)

Get is required by ValueExtractor interface

type Opt

type Opt func(f *HTTPFile)

Opt is option when parse HTTPFile

type Replacer

type Replacer interface {
	// Get return the value by key, if not found key, should return "", false
	Get(key string) (string, bool)
}

Replacer transform key to value

type Report

type Report struct {
	TotalRequests         int
	Currency              int
	Successed             int
	RateLimit             int
	Failed                int
	TotalSend             int
	TotalRecv             int
	RequestTotalTimeUsed  float64
	ResponseTotalTimeUsed float64
	RequestPerSecond      int
	ResponsePerSecond     int
	SendSpeed             float64
	RecvSpeed             float64
	AvgTimeUsed           float64
	MaxTimeUsed           float64
	MinTimeUsed           float64
	P50TimeUsed           float64
	P75TimeUsed           float64
	P90TimeUsed           float64
	P95TimeUsed           float64
	P99TimeUsed           float64
	Stats                 []Stat
}

Report is the statatics of results

func ReportStat

func ReportStat(stats []Stat, totalTimeUsed float64) Report

ReportStat generate report for stats

type Stat

type Stat struct {
	Requests      int
	TimeConsuming float64
	BytesSend     int
	BytesReceived int
	Successed     int
	Failed        int
}

Stat is the file execute time

func Bench

func Bench(file *HTTPFile, connections, requests, rateLimit int) ([]Stat, float64)

Bench the httpfile

Jump to

Keyboard shortcuts

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