lowhttp

package
v1.2.3-sp1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: AGPL-3.0 Imports: 58 Imported by: 4

Documentation

Index

Constants

View Source
const (
	FINALBIT               = 1 << 7
	RSV1BIT                = 1 << 6
	MASKBIT                = 1 << 7
	RESET_MESSAGE_TYPE_BIT = 0b11110000
	FRAME_TYPE_BIT         = 0b00001111
	TWO_BYTE_BIT           = 0b01111110
	EIGHT_BYTE_BIT         = 0b01111111

	TWO_BYTE_SIZE  = 65535
	SEVEN_BIT_SIZE = 125 // 根据websocket协议,126和127分别代表用后续两个字节/八个字节表示长度,所以这里只能用125

	DEFAULT_TEXT_MESSAGE_FISRT_BYTE = 0b10000001

	TextMessage     = 1
	BinaryMessage   = 2
	CloseMessage    = 8
	PingMessage     = 9
	PongMessage     = 10
	ContinueMessage = 0
)
View Source
const (
	CRLF = "\r\n"
)
View Source
const CookieTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

CookieTimeFormat is the time format to use when generating times in HTTP headers. It is like time.RFC1123 but hard-codes GMT as the time zone. The time being formatted must be in UTC for Format to generate the correct format.

For parsing this time format, see ParseTime.

Variables

View Source
var CookiejarPool sync.Map
View Source
var GetProxyConn = utils.GetProxyConn
View Source
var GetProxyConnWithContext = utils.GetProxyConnWithContext
View Source
var (
	// Add four bytes as specified in RFC
	// Add final block to squelch unexpected EOF error from flate reader
	TAIL = []byte{0, 0, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff}
)

Functions

func AddConnectionClosed

func AddConnectionClosed(raw []byte) []byte

func AddOrUpgradeCookie

func AddOrUpgradeCookie(raw []byte, value string) ([]byte, error)

func AppendHTTPPacketCookie added in v1.2.3

func AppendHTTPPacketCookie(packet []byte, key string, value any) []byte

func AppendHTTPPacketFormEncoded added in v1.2.4

func AppendHTTPPacketFormEncoded(packet []byte, key, value string) []byte

func AppendHTTPPacketHeader added in v1.2.3

func AppendHTTPPacketHeader(packet []byte, headerKey string, headerValue any) []byte

func AppendHTTPPacketPath added in v1.2.3

func AppendHTTPPacketPath(packet []byte, p string) []byte

func AppendHTTPPacketPostParam added in v1.2.3

func AppendHTTPPacketPostParam(packet []byte, key, value string) []byte

func AppendHTTPPacketQueryParam added in v1.2.3

func AppendHTTPPacketQueryParam(packet []byte, key, value string) []byte

func AppendHTTPPacketUploadFile added in v1.2.4

func AppendHTTPPacketUploadFile(packet []byte, fieldName, fileName string, fileContent interface{}, contentType ...string) []byte

func AppendHeaderToHTTPPacket

func AppendHeaderToHTTPPacket(raw []byte, line string) []byte

func CharsetToUTF8

func CharsetToUTF8(bodyRaw []byte, mimeType string, originCharset string) ([]byte, string)

func ComputeWebsocketAcceptKey

func ComputeWebsocketAcceptKey(websocketKey string) string

func ConnectVulinboxAgent added in v1.2.3

func ConnectVulinboxAgent(addr string, handler func(request []byte), onPing ...func()) (func(), error)

func ConnectVulinboxAgentEx added in v1.2.3

func ConnectVulinboxAgentEx(addr string, handler func(request []byte), onPing func(), onClose func()) (func(), error)

func ConnectVulinboxAgentRaw added in v1.2.3

func ConnectVulinboxAgentRaw(addr string, handler func([]byte), onClose func()) (func(), error)

func ContentEncodingDecode

func ContentEncodingDecode(contentEncoding string, bodyRaw []byte) (finalResult []byte, fixed bool)

func ConvertHTTPRequestToFuzzTag

func ConvertHTTPRequestToFuzzTag(i []byte) []byte

func CookieSafeQuoteString added in v1.2.2

func CookieSafeQuoteString(i string) string

func CookieSafeUnquoteString added in v1.2.2

func CookieSafeUnquoteString(i string) string

func CookiesToString

func CookiesToString(cookies []*http.Cookie) string

func CopyRequest

func CopyRequest(r *http.Request) *http.Request

func CurlToHTTPRequest

func CurlToHTTPRequest(i string) ([]byte, error)

func DebugEchoServer added in v1.2.3

func DebugEchoServer() (string, int)

func DebugEchoServerContext added in v1.2.3

func DebugEchoServerContext(ctx context.Context) (string, int)

func DeleteHTTPPacketCookie added in v1.2.3

func DeleteHTTPPacketCookie(packet []byte, key string) []byte

func DeleteHTTPPacketForm added in v1.2.4

func DeleteHTTPPacketForm(packet []byte, key string) []byte

func DeleteHTTPPacketHeader added in v1.2.3

func DeleteHTTPPacketHeader(packet []byte, headerKey string) []byte

func DeleteHTTPPacketPostParam added in v1.2.3

func DeleteHTTPPacketPostParam(packet []byte, key string) []byte

func DeleteHTTPPacketQueryParam added in v1.2.3

func DeleteHTTPPacketQueryParam(packet []byte, key string) []byte

func ExtractBodyFromHTTPResponseRaw

func ExtractBodyFromHTTPResponseRaw(res []byte) ([]byte, error)

func ExtractBoundaryFromBody

func ExtractBoundaryFromBody(raw interface{}) string

func ExtractCookieJarFromHTTPResponse

func ExtractCookieJarFromHTTPResponse(rawResponse []byte) []*http.Cookie

func ExtractStatusCodeFromResponse

func ExtractStatusCodeFromResponse(raw []byte) int

func ExtractURLFromHTTPRequest

func ExtractURLFromHTTPRequest(r *http.Request, https bool) (*url.URL, error)

func ExtractURLFromHTTPRequestRaw

func ExtractURLFromHTTPRequestRaw(req []byte, isHttps bool) (*url.URL, error)

func ExtractWebsocketURLFromHTTPRequest

func ExtractWebsocketURLFromHTTPRequest(req *http.Request) (bool, string)

func FetchBannerFromHostPort

func FetchBannerFromHostPort(
	baseCtx context.Context, host string, port interface{}, size int64, noWaitBanner bool,
	forceHTTPS bool,
	noFollowRedirect bool,
) []byte

https://github.com/bradleyfalzon/tlsx

func FixHTTPPacketCRLF

func FixHTTPPacketCRLF(raw []byte, noFixLength bool) []byte

func FixHTTPRequestOut

func FixHTTPRequestOut(raw []byte) []byte

func FixHTTPResponse

func FixHTTPResponse(raw []byte) (rsp []byte, body []byte, _ error)

FixHTTPResponse try its best to fix and present human-readable response

func FixMultipartBody

func FixMultipartBody(i []byte) (string, []byte)

状态机

func FixRequestHostAndPort added in v1.2.3

func FixRequestHostAndPort(r *http.Request)

func GetAllHTTPRequestPostParams added in v1.2.3

func GetAllHTTPRequestPostParams(packet []byte) map[string]string

func GetAllHTTPRequestQueryParams added in v1.2.3

func GetAllHTTPRequestQueryParams(packet []byte) map[string]string

func GetCookiejar

func GetCookiejar(session interface{}) http.CookieJar

func GetHTTPPacketBody added in v1.2.3

func GetHTTPPacketBody(packet []byte) []byte

func GetHTTPPacketContentType added in v1.2.3

func GetHTTPPacketContentType(packet []byte) string

func GetHTTPPacketCookie added in v1.2.3

func GetHTTPPacketCookie(packet []byte, key string) string

func GetHTTPPacketCookieFirst added in v1.2.3

func GetHTTPPacketCookieFirst(packet []byte, key string) string

func GetHTTPPacketCookieValues added in v1.2.3

func GetHTTPPacketCookieValues(packet []byte, key string) []string

func GetHTTPPacketCookies added in v1.2.3

func GetHTTPPacketCookies(packet []byte) map[string]string

func GetHTTPPacketCookiesFull added in v1.2.3

func GetHTTPPacketCookiesFull(packet []byte) map[string][]string

func GetHTTPPacketFirstLine added in v1.2.4

func GetHTTPPacketFirstLine(packet []byte) (string, string, string)

func GetHTTPPacketHeader added in v1.2.3

func GetHTTPPacketHeader(packet []byte, key string) string

func GetHTTPPacketHeaders added in v1.2.3

func GetHTTPPacketHeaders(packet []byte) map[string]string

func GetHTTPPacketHeadersFull added in v1.2.3

func GetHTTPPacketHeadersFull(packet []byte) map[string][]string

func GetHTTPPacketJSONPath added in v1.2.3

func GetHTTPPacketJSONPath(packet []byte, key string) any

func GetHTTPPacketJSONValue added in v1.2.3

func GetHTTPPacketJSONValue(packet []byte, key string) any

func GetHTTPRequestPostParam added in v1.2.3

func GetHTTPRequestPostParam(packet []byte, key string) string

func GetHTTPRequestPostParamFull added in v1.2.3

func GetHTTPRequestPostParamFull(packet []byte, key string) []string

func GetHTTPRequestQueryParam added in v1.2.3

func GetHTTPRequestQueryParam(packet []byte, key string) string

func GetHTTPRequestQueryParamFull added in v1.2.3

func GetHTTPRequestQueryParamFull(packet []byte, key string) []string

func GetHostsFilePath

func GetHostsFilePath() string

func GetOverrideContentType

func GetOverrideContentType(bodyPrescan []byte, contentType string) (overrideContentType string, originCharset string)

func GetRedirectFromHTTPResponse

func GetRedirectFromHTTPResponse(rawResponse []byte, jsRedirect bool) string

func GetStatusCodeFromResponse added in v1.2.3

func GetStatusCodeFromResponse(packet []byte) int

func GetSystemEtcHosts

func GetSystemEtcHosts() map[string]string

func GetSystemHostByName

func GetSystemHostByName(domain string) (string, bool)

func GetTLSConn added in v1.2.2

func GetTLSConn(isGM bool, enableHttp2 bool, host string, rawConn net.Conn, timeout time.Duration) (net.Conn, error)

func HTTP2RequestToHTTP

func HTTP2RequestToHTTP(framer *http2.Framer) ([]byte, error)

func HTTP2ResponseToHTTP

func HTTP2ResponseToHTTP(frame *http2.Frame) ([]byte, error)

func HTTPPacketForceChunked

func HTTPPacketForceChunked(raw []byte) []byte

func HTTPRequestToHTTP2

func HTTPRequestToHTTP2(schema string, host string, conn net.Conn, raw []byte, noFixContentLength bool) ([]byte, error)

func IsChunkedHeaderLine added in v1.2.3

func IsChunkedHeaderLine(line string) bool

func IsHeader added in v1.2.4

func IsHeader(headerLine, wantHeader string) bool

func IsMultipartFormDataRequest

func IsMultipartFormDataRequest(req []byte) bool

func IsPermessageDeflate

func IsPermessageDeflate(headers http.Header) bool

func IsPrint

func IsPrint(s string) bool

func MergeCookies

func MergeCookies(cookies ...*http.Cookie) string

func MergeUrlFromHTTPRequest

func MergeUrlFromHTTPRequest(rawRequest []byte, target string, isHttps bool) string

func ParseBytesToHTTPResponse

func ParseBytesToHTTPResponse(res []byte) (*http.Response, error)

func ParseBytesToHttpRequest

func ParseBytesToHttpRequest(raw []byte) (*http.Request, error)

func ParseCookie

func ParseCookie(i string) []*http.Cookie

func ParseStringToHTTPResponse

func ParseStringToHTTPResponse(res string) (*http.Response, error)

func ParseStringToHttpRequest

func ParseStringToHttpRequest(raw string) (*http.Request, error)

func ParseUrlToHttpRequestRaw

func ParseUrlToHttpRequestRaw(method string, i interface{}) (bool, []byte, error)

func ReadHTTPPacketBodySize

func ReadHTTPPacketBodySize(raw []byte) (cl int, chunked bool)

func ReadHTTPPacketSafe

func ReadHTTPPacketSafe(r *bufio.Reader) ([]byte, error)

func ReadHTTPRequest

func ReadHTTPRequest(reader *bufio.Reader) (*http.Request, error)

func ReadHTTPRequestEx

func ReadHTTPRequestEx(reader *bufio.Reader, loadbody bool) (*http.Request, error)

func ReadHTTPResponseEx

func ReadHTTPResponseEx(reader *bufio.Reader, loadbody bool) (*http.Response, []byte, error)

func RegisterSaveHTTPFlowHandler

func RegisterSaveHTTPFlowHandler(h saveHTTPFlowHandler)

func RemoveCEHeaders

func RemoveCEHeaders(headerBytes []byte) []byte

func RemoveZeroContentLengthHTTPHeader

func RemoveZeroContentLengthHTTPHeader(raw []byte) []byte

func ReplaceAllHTTPPacketPostParams added in v1.2.4

func ReplaceAllHTTPPacketPostParams(packet []byte, values map[string]string) []byte

func ReplaceAllHTTPPacketQueryParams added in v1.2.4

func ReplaceAllHTTPPacketQueryParams(packet []byte, values map[string]string) []byte

func ReplaceHTTPPacketBasicAuth added in v1.2.4

func ReplaceHTTPPacketBasicAuth(packet []byte, username, password string) []byte

func ReplaceHTTPPacketBody

func ReplaceHTTPPacketBody(raw []byte, body []byte, chunk bool) []byte

func ReplaceHTTPPacketBodyEx

func ReplaceHTTPPacketBodyEx(raw []byte, body []byte, chunk bool, forceCL bool) []byte

func ReplaceHTTPPacketBodyFast added in v1.2.3

func ReplaceHTTPPacketBodyFast(packet []byte, body []byte) []byte

func ReplaceHTTPPacketCookie added in v1.2.3

func ReplaceHTTPPacketCookie(packet []byte, key string, value any) []byte

func ReplaceHTTPPacketFirstLine added in v1.2.3

func ReplaceHTTPPacketFirstLine(packet []byte, firstLine string) []byte

func ReplaceHTTPPacketHeader added in v1.2.3

func ReplaceHTTPPacketHeader(packet []byte, headerKey string, headerValue any) []byte

func ReplaceHTTPPacketHost added in v1.2.4

func ReplaceHTTPPacketHost(packet []byte, host string) []byte

func ReplaceHTTPPacketMethod added in v1.2.4

func ReplaceHTTPPacketMethod(packet []byte, newMethod string) []byte

func ReplaceHTTPPacketPath added in v1.2.3

func ReplaceHTTPPacketPath(packet []byte, p string) []byte

func ReplaceHTTPPacketPostParam added in v1.2.3

func ReplaceHTTPPacketPostParam(packet []byte, key, value string) []byte

func ReplaceHTTPPacketQueryParam added in v1.2.3

func ReplaceHTTPPacketQueryParam(packet []byte, key, value string) []byte

func ReplaceMIMEType

func ReplaceMIMEType(headerBytes []byte, mimeType string) []byte

func SaveResponse

func SaveResponse(r *LowhttpResponse)

func ShouldSendReqContentLength

func ShouldSendReqContentLength(method string, contentLength int64) bool

ShouldSendReqContentLength reports whether the http2.Transport should send a "content-length" request header. This logic is basically a copy of the net/http transferWriter.shouldSendContentLength. The contentLength is the corrected contentLength (so 0 means actually 0, not unknown). -1 means unknown.

func SplitHTTPHeader

func SplitHTTPHeader(i string) (string, string)

func SplitHTTPHeadersAndBodyFromPacket

func SplitHTTPHeadersAndBodyFromPacket(raw []byte, hook ...func(line string)) (string, []byte)

func SplitHTTPHeadersAndBodyFromPacketEx

func SplitHTTPHeadersAndBodyFromPacketEx(raw []byte, mf func(method string, requestUri string, proto string) error, hook ...func(line string)) (string, []byte)

func SplitHTTPPacket added in v1.2.3

func SplitHTTPPacket(
	raw []byte,
	reqFirstLine func(method string, requestUri string, proto string) error,
	rspFirstLine func(proto string, code int, codeMsg string) error,
	hook ...func(line string) string) (string, []byte)

SplitHTTPPacket split http packet to headers and body reqFirstLine: method, requestUri, proto: error for empty result rspFirstLine: proto, code, codeMsg: error for empty result hook: hook func

func SplitHTTPPacketFast added in v1.2.3

func SplitHTTPPacketFast(raw any) (string, []byte)

func SplitKV

func SplitKV(i string) (string, string)

func ToLower

func ToLower(s string) (lower string, ok bool)

func ToUnquoteFuzzTag

func ToUnquoteFuzzTag(i []byte) string

func TrimLeftHTTPPacket

func TrimLeftHTTPPacket(raw []byte) []byte

func TrimRightHTTPPacket

func TrimRightHTTPPacket(raw []byte) []byte

func TrimSpaceHTTPPacket

func TrimSpaceHTTPPacket(raw []byte) []byte

func UrlToGetRequestPacket

func UrlToGetRequestPacket(u string, originRequest []byte, originRequestHttps bool, cookies ...*http.Cookie) []byte

func UrlToRequestPacket added in v1.2.3

func UrlToRequestPacket(method string, u string, originRequest []byte, originRequestHttps bool, cookies ...*http.Cookie) []byte

func WebsocketFrameToData

func WebsocketFrameToData(frame *Frame) (data []byte)

Types

type CurlCommand added in v1.2.3

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

CurlCommand contains exec.Command compatible slice + helpers

func GetCurlCommand added in v1.2.3

func GetCurlCommand(isHttps bool, req []byte) (*CurlCommand, error)

GetCurlCommand returns a CurlCommand corresponding to an http.Request

func (*CurlCommand) String added in v1.2.3

func (c *CurlCommand) String() string

String returns a ready to copy/paste command

type Frame

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

func DataToWebsocketControlFrame

func DataToWebsocketControlFrame(messageType int, data []byte, mask bool) (frame *Frame, err error)

func DataToWebsocketFrame

func DataToWebsocketFrame(data []byte, firstByte byte, mask bool) (frame *Frame, err error)

func (*Frame) Bytes

func (f *Frame) Bytes() ([]byte, []byte)

func (*Frame) GetMaskingKey

func (f *Frame) GetMaskingKey() []byte

func (*Frame) IsControl

func (f *Frame) IsControl() bool

func (*Frame) RawPayloadData

func (f *Frame) RawPayloadData() []byte

func (*Frame) SetMaskingKey

func (f *Frame) SetMaskingKey(r []byte)

func (*Frame) Show

func (f *Frame) Show()

func (*Frame) Type

func (f *Frame) Type() int

type FrameReader

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

func NewFrameReader

func NewFrameReader(r io.Reader, isDeflate bool) *FrameReader

func NewFrameReaderFromBufio

func NewFrameReaderFromBufio(r *bufio.Reader, isDeflate bool) *FrameReader

func (*FrameReader) ReadFrame

func (fr *FrameReader) ReadFrame() (frame *Frame, err error)

type FrameWriter

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

func NewFrameWriter

func NewFrameWriter(w io.Writer, isDeflate bool) *FrameWriter

func NewFrameWriterFromBufio

func NewFrameWriterFromBufio(w *bufio.Writer, isDeflate bool) *FrameWriter

func (*FrameWriter) Flush

func (fw *FrameWriter) Flush() error

func (*FrameWriter) WriteBinary

func (fw *FrameWriter) WriteBinary(data []byte, mask bool, headerBytes ...byte) (err error)

func (*FrameWriter) WriteFrame

func (fw *FrameWriter) WriteFrame(frame *Frame, messageTypes ...int) (err error)

func (*FrameWriter) WritePong

func (fw *FrameWriter) WritePong(data []byte, mask bool) (err error)

func (*FrameWriter) WriteRaw

func (fw *FrameWriter) WriteRaw(raw []byte) (err error)

func (*FrameWriter) WriteText

func (fw *FrameWriter) WriteText(data []byte, mask bool, headerBytes ...byte) (err error)

type LowhttpExecConfig

type LowhttpExecConfig struct {
	Host                 string
	Port                 int
	Packet               []byte
	Https                bool
	ResponseCallback     func(response *LowhttpResponse)
	Http2                bool
	GmTLS                bool
	Timeout              time.Duration
	RedirectTimes        int
	RetryTimes           int
	RetryInStatusCode    []int
	RetryNotInStatusCode []int
	RetryWaitTime        time.Duration
	RetryMaxWaitTime     time.Duration
	JsRedirect           bool
	Proxy                []string
	NoFixContentLength   bool
	RedirectHandler      func(bool, []byte, []byte) bool
	Session              interface{}
	BeforeDoRequest      func([]byte) []byte
	Ctx                  context.Context
	SaveHTTPFlow         bool
	RequestSource        string
	EtcHosts             map[string]string
	DNSServers           []string
	DefaultDnsServerType string // system or custom, if DNSServers is empty, use system dns or custom dns, default is system
	RuntimeId            string
	FromPlugin           string
}

func NewLowhttpOption

func NewLowhttpOption() *LowhttpExecConfig

new LowhttpOpt

type LowhttpOpt

type LowhttpOpt func(o *LowhttpExecConfig)

func WithBeforeDoRequest

func WithBeforeDoRequest(h func([]byte) []byte) LowhttpOpt

func WithContext

func WithContext(ctx context.Context) LowhttpOpt

func WithDNSServers

func WithDNSServers(servers []string) LowhttpOpt

func WithETCHosts

func WithETCHosts(hosts map[string]string) LowhttpOpt

func WithFromPlugin added in v1.2.3

func WithFromPlugin(fromPlugin string) LowhttpOpt

func WithGmTLS added in v1.2.2

func WithGmTLS(b bool) LowhttpOpt

func WithHost

func WithHost(host string) LowhttpOpt

func WithHttp2

func WithHttp2(Http2 bool) LowhttpOpt

func WithHttps

func WithHttps(https bool) LowhttpOpt

func WithJsRedirect

func WithJsRedirect(jsRedirect bool) LowhttpOpt

func WithNoFixContentLength

func WithNoFixContentLength(noFixContentLength bool) LowhttpOpt

func WithPacketBytes added in v1.2.4

func WithPacketBytes(packet []byte) LowhttpOpt

func WithPort

func WithPort(port int) LowhttpOpt

func WithProxy

func WithProxy(proxy ...string) LowhttpOpt

func WithRedirectHandler

func WithRedirectHandler(redirectHandler func(bool, []byte, []byte) bool) LowhttpOpt

func WithRedirectTimes

func WithRedirectTimes(redirectTimes int) LowhttpOpt

func WithRequest added in v1.2.4

func WithRequest(packet any) LowhttpOpt

func WithResponseCallback added in v1.2.4

func WithResponseCallback(h func(i *LowhttpResponse)) LowhttpOpt

func WithRetryInStatusCode

func WithRetryInStatusCode(sc []int) LowhttpOpt

func WithRetryMaxWaitTime

func WithRetryMaxWaitTime(retryMaxWaitTime time.Duration) LowhttpOpt

func WithRetryNotInStatusCode

func WithRetryNotInStatusCode(sc []int) LowhttpOpt

func WithRetryTimes

func WithRetryTimes(retryTimes int) LowhttpOpt

func WithRetryWaitTime

func WithRetryWaitTime(retryWaitTime time.Duration) LowhttpOpt

func WithRuntimeId added in v1.2.3

func WithRuntimeId(runtimeId string) LowhttpOpt

func WithSaveHTTPFlow

func WithSaveHTTPFlow(b bool) LowhttpOpt

func WithSession

func WithSession(session interface{}) LowhttpOpt

func WithSource

func WithSource(s string) LowhttpOpt

func WithTimeout

func WithTimeout(timeout time.Duration) LowhttpOpt

func WithTimeoutFloat added in v1.2.4

func WithTimeoutFloat(i float64) LowhttpOpt

type LowhttpResponse

type LowhttpResponse struct {
	RawPacket          []byte
	RedirectRawPackets []*RedirectFlow
	PortIsOpen         bool
	TraceInfo          *LowhttpTraceInfo
	Url                string
	RemoteAddr         string
	Proxy              string
	Https              bool
	Http2              bool
	RawRequest         []byte
	Source             string // 请求源
	RuntimeId          string
	FromPlugin         string
}

func HTTP added in v1.2.4

func HTTP(opts ...LowhttpOpt) (*LowhttpResponse, error)

func HTTPWithoutRedirect added in v1.2.4

func HTTPWithoutRedirect(opts ...LowhttpOpt) (*LowhttpResponse, error)

SendHttpRequestWithRawPacketWithOpt

func (*LowhttpResponse) GetDurationFloat

func (l *LowhttpResponse) GetDurationFloat() float64

type LowhttpTraceInfo

type LowhttpTraceInfo struct {
	AvailableDNSServers []string
	// DNS 完整请求时间
	DNSTime time.Duration
	// 获取一个连接的耗时
	ConnTime time.Duration
	// 服务器处理耗时,计算从连接建立到客户端收到第一个字节的时间间隔
	ServerTime time.Duration
	// 完整请求的耗时
	TotalTime time.Duration
}

func (*LowhttpTraceInfo) GetServerDurationMS

func (l *LowhttpTraceInfo) GetServerDurationMS() int64

type RedirectFlow added in v1.2.4

type RedirectFlow struct {
	IsHttps  bool
	Request  []byte
	Response []byte
}

type WebHookServer

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

func NewWebHookServer

func NewWebHookServer(port int, cb func(data interface{})) *WebHookServer

func NewWebHookServerEx

func NewWebHookServerEx(port int, cb func(data interface{})) *WebHookServer

func (*WebHookServer) Addr

func (w *WebHookServer) Addr() string

func (*WebHookServer) Shutdown

func (w *WebHookServer) Shutdown()

func (*WebHookServer) Start

func (w *WebHookServer) Start()

type WebsocketClient

type WebsocketClient struct {
	Request           []byte
	Response          []byte
	FromServerOnce    *sync.Once
	FromServerHandler func([]byte)
	Context           context.Context
	// contains filtered or unexported fields
}

func NewWebsocketClient

func NewWebsocketClient(packet []byte, opt ...WebsocketClientOpt) (*WebsocketClient, error)

func (*WebsocketClient) StartFromServer

func (c *WebsocketClient) StartFromServer()

func (*WebsocketClient) Stop

func (c *WebsocketClient) Stop()

func (*WebsocketClient) Wait

func (c *WebsocketClient) Wait()

func (*WebsocketClient) Write

func (c *WebsocketClient) Write(r []byte) error

func (*WebsocketClient) WriteBinary

func (c *WebsocketClient) WriteBinary(r []byte) error

func (*WebsocketClient) WritePong

func (c *WebsocketClient) WritePong(r []byte) error

func (*WebsocketClient) WriteText

func (c *WebsocketClient) WriteText(r []byte) error

type WebsocketClientConfig

type WebsocketClientConfig struct {
	Proxy             string
	TotalTimeout      time.Duration
	TLS               bool
	FromServerHandler func([]byte)
	Context           context.Context

	// Host Port
	Host string
	Port int
	// contains filtered or unexported fields
}

type WebsocketClientOpt

type WebsocketClientOpt func(config *WebsocketClientConfig)

func WithWebsocketFromServerHandler

func WithWebsocketFromServerHandler(f func([]byte)) WebsocketClientOpt

func WithWebsocketHost

func WithWebsocketHost(t string) WebsocketClientOpt

func WithWebsocketPort

func WithWebsocketPort(t int) WebsocketClientOpt

func WithWebsocketProxy

func WithWebsocketProxy(t string) WebsocketClientOpt

func WithWebsocketTLS

func WithWebsocketTLS(t bool) WebsocketClientOpt

func WithWebsocketTotalTimeout

func WithWebsocketTotalTimeout(t float64) WebsocketClientOpt

func WithWebsocketWithContext

func WithWebsocketWithContext(ctx context.Context) WebsocketClientOpt

Directories

Path Synopsis
Package http2 implements the HTTP/2 protocol.
Package http2 implements the HTTP/2 protocol.
hpack
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.
Package hpack implements HPACK, a compression format for efficiently representing HTTP header fields in the context of HTTP/2.

Jump to

Keyboard shortcuts

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