internal

package
v0.0.0-...-4282750 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeName = "Content-Type"
	ContentTypeJSON = "application/json;charset=utf-8"
)

Variables

View Source
var Debug = ss.Must(ss.GetenvBool("DEBUG", false))
View Source
var DemoProfile []byte

Functions

func CloneBytes

func CloneBytes(b []byte) []byte

func DealUploadFilePath

func DealUploadFilePath(ctx context.Context, uploadReader FileReader, postFileCh chan *UploadChanValue, cache bool)

func ErrorIf

func ErrorIf(b bool, err1, err2 error) error

func FindReplaceFunc

func FindReplaceFunc(subject, search string, repl func(string) string) string

func FoldFindReplace

func FoldFindReplace(subject, search, replace string) (string, bool)

func FoldReplace

func FoldReplace(subject, search, replace string) string

func Gen

func Gen(s string, mode StringMode) string

func Hjson2Json

func Hjson2Json(s []byte) ([]byte, error)

func If

func If[T any](c bool, a, b T) T

func ParseBodyArg

func ParseBodyArg(body string, stream, lineMode bool) (streamFileName string, bodyBytes []byte, lines chan string)

func ParseFileArg

func ParseFileArg(arg string) (file string, data []byte)

ParseFileArg parse an argument which represents a string content, or @file to represents the file's content.

func Quoted

func Quoted(s, open, close string) (string, bool)

func ReadFileFromPos

func ReadFileFromPos(f *os.File, pos int64) ([]byte, error)

func SetHeader

func SetHeader(r *fasthttp.Request, header, value string)

SetHeader set request header if value is not empty.

func ThroughputStatDial

func ThroughputStatDial(wrap NetworkWrapper, dial fasthttp.DialFunc, r, w *int64) fasthttp.DialFunc

Types

type ChanUploadChanValueReader

type ChanUploadChanValueReader struct {
	Chan chan UploadChanValue
}

func (*ChanUploadChanValueReader) ReadUploadChanValue

func (c *ChanUploadChanValueReader) ReadUploadChanValue() UploadChanValue

type Closers

type Closers []io.Closer

func (Closers) Close

func (closers Closers) Close() (err error)

type DataItem

type DataItem struct {
	Payload util.UploadPayload
}

func (*DataItem) CreateFileField

func (d *DataItem) CreateFileField(fileFieldName string, uploadIndex bool) *util.Multipart

type EnvVars

type EnvVars map[string]string

func (EnvVars) Eval

func (e EnvVars) Eval(s string) string

type FileReader

type FileReader interface {
	Read(cache bool) *UploadChanValue
	Start(ctx context.Context)
}

func CreateFileReader

func CreateFileReader(uploadFileField, upload, saveRandDir string, ant bool) FileReader

type LogFile

type LogFile struct {
	File *os.File

	Pos int64
	sync.Mutex
	// contains filtered or unexported fields
}

func CreateLogFile

func CreateLogFile(verbose int, n int) *LogFile

func (*LogFile) Close

func (f *LogFile) Close() error

func (*LogFile) GetLastLog

func (f *LogFile) GetLastLog() string

func (*LogFile) MarkPos

func (f *LogFile) MarkPos()

func (*LogFile) Remove

func (f *LogFile) Remove() error

func (*LogFile) Write

func (f *LogFile) Write(b *bytes.Buffer)

func (*LogFile) WriteString

func (f *LogFile) WriteString(s string)

type MyConn

type MyConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewMyConn

func NewMyConn(conn net.Conn, r, w *int64) (*MyConn, error)

func (*MyConn) Read

func (c *MyConn) Read(b []byte) (n int, err error)

func (*MyConn) Write

func (c *MyConn) Write(b []byte) (n int, err error)

type NetworkWrapper

type NetworkWrapper func(net.Conn) net.Conn

func NetworkWrap

func NetworkWrap(network string) NetworkWrapper

type Option

type Option struct {
	// 从结果 JSON 中 使用 jj.Get 提取值, 参见 demo.http 中写法
	// 例如:result.id=chinaID,表示设置 @id = jj.Get(responseJSON, "chinaID")
	// 一般配合初始化调用使用,例如从登录结果中提取 accessToken 等
	ResultExpr map[string]string `prefix:"result."`
	SourceExpr map[string]string `prefix:"source."`
	Asserts    map[string]string `prefix:"assert."`
	Tag        string
	Eval       bool
	GoTemplate bool
	Init       bool // 作为初始化调用,例如登录

	JsonBody bool
	Template *template.Template
}

func (*Option) ResultJSONValuer

func (o *Option) ResultJSONValuer(jsonBody []byte, kvs *map[string]string)

func (*Option) SourceJSONValuer

func (o *Option) SourceJSONValuer(jsonBody []byte, kvs *map[string]string)

type Profile

type Profile struct {
	Option

	Query   map[string]string
	RawJSON map[string]string
	Form    map[string]string
	Header  map[string]string
	EnvVars EnvVars
	Body    string
	URL     string
	Method  string

	Comments []string
	// contains filtered or unexported fields
}

func ParseProfileArg

func ParseProfileArg(profileArg []string, envName string) []*Profile

func ParseProfileFile

func ParseProfileFile(fileName, envName string) ([]*Profile, error)

func ParseProfiles

func ParseProfiles(r io.Reader, envName string) ([]*Profile, error)

func (*Profile) CreateReq

func (p *Profile) CreateReq(isTLS bool, req *fasthttp.Request, enableGzip, uploadIndex bool, resultMap map[string]string) (Closers, error)

type RangeValue

type RangeValue struct {
	From string
	To   string

	IsInt   bool
	FromInt int
	ToInt   int
}

func (*RangeValue) Contains

func (r *RangeValue) Contains(s string) bool

type SingleValue

type SingleValue struct {
	Value string
}

func (SingleValue) Contains

func (v SingleValue) Contains(s string) bool

type StringMode

type StringMode int
const (
	IgnoreJSON StringMode = iota
	MayJSON
	SureJSON
)

type Tag

type Tag struct {
	Raw    string
	Values []TagValue
}

func ParseTag

func ParseTag(s string) *Tag

func (*Tag) Contains

func (t *Tag) Contains(s string) bool

func (Tag) String

func (t Tag) String() string

type TagValue

type TagValue interface {
	Contains(s string) bool
}

func NewRangeValue

func NewRangeValue(a, b string) TagValue

type UploadChanValue

type UploadChanValue struct {
	Data        func() *DataItem
	Path        string
	ContentType string
	Type        UploadChanValueType
	UploadExit  bool
}

func (UploadChanValue) GetCachePath

func (v UploadChanValue) GetCachePath() string

type UploadChanValueReader

type UploadChanValueReader interface {
	ReadUploadChanValue() UploadChanValue
}

type UploadChanValueType

type UploadChanValueType int
const (
	NormalFile UploadChanValueType = iota
	DirectBytes
)

type ValUploadChanValueReader

type ValUploadChanValueReader struct {
	Value UploadChanValue
}

func (*ValUploadChanValueReader) ReadUploadChanValue

func (c *ValUploadChanValueReader) ReadUploadChanValue() UploadChanValue

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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