sreq

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Check bool

Check = True to stop workerpool

Functions

func BodyFileUpload

func BodyFileUpload(fileUpload FileParam, Params ...ParamInUploadFile) (*bytes.Buffer, string)

Process Upload file body in Post request

func ConnectWS

func ConnectWS(urlStr string, ft func(input string) string, f func(conn *websocket.Conn))

Create connection WS

for use ft -> template func to create request with input and format data return string

f -> function to handle response

Example

sreq.ConnectWS(url, func(input string) string {
		sreq.ConnectWS(url, func(input string) string {
		req := //somethings
		return string(req)
	}, func(conn *websocket.Conn) {
		for {
			_, message, err := conn.ReadMessage()
			if err != nil {
				log.Println("read:", err)
				return
			}
			//worksomething
		}
	})

func ParseReqFile

func ParseReqFile(filename string, url string) *http.Request

Parse request from file raw

url have http:// or https://

func Sends

func Sends(req []*Request, proxy string, worker int, f func(c DataHandler))

Multi worker to send request

func SetCookie

func SetCookie(req *http.Request, cookies []*http.Cookie) *http.Request

Set cookie for request

func UnzipResp

func UnzipResp(resp *http.Response) string

read body response

Types

type CustomTransport

type CustomTransport struct {
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(proxy string) *CustomTransport

NewTransport return CustomTransport

func (*CustomTransport) ConnDuration

func (tr *CustomTransport) ConnDuration() time.Duration

func (*CustomTransport) Dial

func (tr *CustomTransport) Dial(network, addr string) (net.Conn, error)

func (*CustomTransport) Duration

func (tr *CustomTransport) Duration() time.Duration

func (*CustomTransport) ReqDuration

func (tr *CustomTransport) ReqDuration() time.Duration

func (*CustomTransport) RoundTrip

func (tr *CustomTransport) RoundTrip(r *http.Request) (*http.Response, error)

Handle Time in request

type DataHandler

type DataHandler struct {
	Resp    *http.Response
	Req     *http.Request
	Time    time.Duration
	DataRet []rune
	// contains filtered or unexported fields
}

Data of response store

func Append

func Append(data []DataHandler, temp DataHandler) []DataHandler

Insert new node to array and sort by Index

func Send

func Send(req *Request, proxy string) DataHandler

One worker send request

type FileParam

type FileParam struct {
	NameOfParam string //param of filename
	FileName    string //filename to open
}

Process Upload File with file

type ParamInUploadFile

type ParamInUploadFile struct {
	ParamName  string
	ParamValue string
}

Process Upload File with more param

type Request

type Request struct {
	Req      *http.Request
	Redirect bool   // default false
	DataRet  []rune // default nil
}

Create Request to worker

func AddQueue

func AddQueue(req []*Request, tempreq *Request) []*Request

Add queue to run workerpool

Jump to

Keyboard shortcuts

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