Documentation ¶
Index ¶
- Constants
- Variables
- func AddConnectionClosed(raw []byte) []byte
- func AddOrUpgradeCookie(raw []byte, value string) ([]byte, error)
- func AppendHTTPPacketCookie(packet []byte, key string, value any) []byte
- func AppendHTTPPacketFormEncoded(packet []byte, key, value string) []byte
- func AppendHTTPPacketHeader(packet []byte, headerKey string, headerValue any) []byte
- func AppendHTTPPacketPath(packet []byte, p string) []byte
- func AppendHTTPPacketPostParam(packet []byte, key, value string) []byte
- func AppendHTTPPacketQueryParam(packet []byte, key, value string) []byte
- func AppendHTTPPacketUploadFile(packet []byte, fieldName, fileName string, fileContent interface{}, ...) []byte
- func AppendHeaderToHTTPPacket(raw []byte, line string) []byte
- func CharsetToUTF8(bodyRaw []byte, mimeType string, originCharset string) ([]byte, string)
- func ComputeWebsocketAcceptKey(websocketKey string) string
- func ContentEncodingDecode(contentEncoding string, bodyRaw []byte) (finalResult []byte, fixed bool)
- func ConvertHTTPRequestToFuzzTag(i []byte) []byte
- func CookieSafeQuoteString(i string) string
- func CookieSafeUnquoteString(i string) string
- func CookiesToString(cookies []*http.Cookie) string
- func CopyRequest(r *http.Request) *http.Request
- func CurlToHTTPRequest(i string) ([]byte, error)
- func DebugEchoServer() (string, int)
- func DebugEchoServerContext(ctx context.Context) (string, int)
- func DeleteHTTPPacketCookie(packet []byte, key string) []byte
- func DeleteHTTPPacketForm(packet []byte, key string) []byte
- func DeleteHTTPPacketHeader(packet []byte, headerKey string) []byte
- func DeleteHTTPPacketPostParam(packet []byte, key string) []byte
- func DeleteHTTPPacketQueryParam(packet []byte, key string) []byte
- func DeletePacketEncoding(raw []byte) []byte
- func ExtractBodyFromHTTPResponseRaw(res []byte) ([]byte, error)
- func ExtractBoundaryFromBody(raw interface{}) string
- func ExtractCookieJarFromHTTPResponse(rawResponse []byte) []*http.Cookie
- func ExtractStatusCodeFromResponse(raw []byte) int
- func ExtractURLFromHTTPRequest(r *http.Request, https bool) (*url.URL, error)
- func ExtractURLFromHTTPRequestRaw(req []byte, isHttps bool) (*url.URL, error)
- func ExtractWebsocketURLFromHTTPRequest(req *http.Request) (bool, string)
- func FixHTTPPacketCRLF(raw []byte, noFixLength bool) []byte
- func FixHTTPRequest(raw []byte) []byte
- func FixHTTPResponse(raw []byte) (rsp []byte, body []byte, _ error)
- func FixMultipartBody(i []byte) (string, []byte)
- func FixRequestHostAndPort(r *http.Request)
- func GetAllHTTPRequestPostParams(packet []byte) map[string]string
- func GetAllHTTPRequestQueryParams(packet []byte) map[string]string
- func GetCookiejar(session interface{}) http.CookieJar
- func GetHTTPPacketBody(packet []byte) []byte
- func GetHTTPPacketContentType(packet []byte) string
- func GetHTTPPacketCookie(packet []byte, key string) string
- func GetHTTPPacketCookieFirst(packet []byte, key string) string
- func GetHTTPPacketCookieValues(packet []byte, key string) []string
- func GetHTTPPacketCookies(packet []byte) map[string]string
- func GetHTTPPacketCookiesFull(packet []byte) map[string][]string
- func GetHTTPPacketFirstLine(packet []byte) (string, string, string)
- func GetHTTPPacketHeader(packet []byte, key string) string
- func GetHTTPPacketHeaders(packet []byte) map[string]string
- func GetHTTPPacketHeadersFull(packet []byte) map[string][]string
- func GetHTTPPacketJSONPath(packet []byte, key string) any
- func GetHTTPPacketJSONValue(packet []byte, key string) any
- func GetHTTPRequestPostParam(packet []byte, key string) string
- func GetHTTPRequestPostParamFull(packet []byte, key string) []string
- func GetHTTPRequestQueryParam(packet []byte, key string) string
- func GetHTTPRequestQueryParamFull(packet []byte, key string) []string
- func GetHostsFilePath() string
- func GetOverrideContentType(bodyPrescan []byte, contentType string) (overrideContentType string, originCharset string)
- func GetRedirectFromHTTPResponse(rawResponse []byte, jsRedirect bool) string
- func GetStatusCodeFromResponse(packet []byte) int
- func GetSystemEtcHosts() map[string]string
- func GetSystemHostByName(domain string) (string, bool)
- func HTTP2RequestToHTTP(framer *http2.Framer) ([]byte, error)
- func HTTP2ResponseToHTTP(frame *http2.Frame) ([]byte, error)
- func HTTPPacketForceChunked(raw []byte) []byte
- func HTTPRequestToHTTP2(schema string, host string, conn net.Conn, raw []byte, noFixContentLength bool) ([]byte, error)
- func IsChunkedHeaderLine(line string) bool
- func IsHeader(headerLine, wantHeader string) bool
- func IsMultipartFormDataRequest(req []byte) bool
- func IsPermessageDeflate(headers http.Header) bool
- func IsPrint(s string) bool
- func IsResp(data any) bool
- func MergeCookies(cookies ...*http.Cookie) string
- func MergeUrlFromHTTPRequest(rawRequest []byte, target string, isHttps bool) string
- func NewRequestPacketFromMethod(method string, u string, originRequest []byte, originRequestHttps bool, ...) []byte
- func ParseBytesToHTTPResponse(res []byte) (*http.Response, error)
- func ParseBytesToHttpRequest(raw []byte) (*http.Request, error)
- func ParseCookie(i string) []*http.Cookie
- func ParseStringToHTTPResponse(res string) (*http.Response, error)
- func ParseStringToHttpRequest(raw string) (*http.Request, error)
- func ParseUrlToHttpRequestRaw(method string, i interface{}) (bool, []byte, error)
- func ReadHTTPPacketBodySize(raw []byte) (cl int, chunked bool)
- func RegisterSaveHTTPFlowHandler(h saveHTTPFlowHandler)
- func RemoveCEHeaders(headerBytes []byte) []byte
- func RemoveZeroContentLengthHTTPHeader(raw []byte) []byte
- func ReplaceAllHTTPPacketPostParams(packet []byte, values map[string]string) []byte
- func ReplaceAllHTTPPacketQueryParams(packet []byte, values map[string]string) []byte
- func ReplaceHTTPPacketBasicAuth(packet []byte, username, password string) []byte
- func ReplaceHTTPPacketBody(raw []byte, body []byte, chunk bool) []byte
- func ReplaceHTTPPacketBodyEx(raw []byte, body []byte, chunk bool, forceCL bool) []byte
- func ReplaceHTTPPacketBodyFast(packet []byte, body []byte) []byte
- func ReplaceHTTPPacketCookie(packet []byte, key string, value any) []byte
- func ReplaceHTTPPacketFirstLine(packet []byte, firstLine string) []byte
- func ReplaceHTTPPacketHeader(packet []byte, headerKey string, headerValue any) []byte
- func ReplaceHTTPPacketHost(packet []byte, host string) []byte
- func ReplaceHTTPPacketMethod(packet []byte, newMethod string) []byte
- func ReplaceHTTPPacketPath(packet []byte, p string) []byte
- func ReplaceHTTPPacketPostParam(packet []byte, key, value string) []byte
- func ReplaceHTTPPacketQueryParam(packet []byte, key, value string) []byte
- func ReplaceMIMEType(headerBytes []byte, mimeType string) []byte
- func SaveResponse(r *LowhttpResponse)
- func ShouldSendReqContentLength(method string, contentLength int64) bool
- func SplitHTTPHeader(i string) (string, string)
- func SplitHTTPHeadersAndBodyFromPacket(raw []byte, hook ...func(line string)) (string, []byte)
- func SplitHTTPHeadersAndBodyFromPacketEx(raw []byte, mf func(method string, requestUri string, proto string) error, ...) (string, []byte)
- func SplitHTTPPacket(raw []byte, ...) (string, []byte)
- func SplitHTTPPacketFast(raw any) (string, []byte)
- func SplitKV(i string) (string, string)
- func ToLower(s string) (lower string, ok bool)
- func ToUnquoteFuzzTag(i []byte) string
- func TrimLeftHTTPPacket(raw []byte) []byte
- func TrimRightHTTPPacket(raw []byte) []byte
- func TrimSpaceHTTPPacket(raw []byte) []byte
- func UrlToGetRequestPacket(u string, originRequest []byte, originRequestHttps bool, ...) []byte
- func UrlToGetRequestPacketWithResponse(u string, originRequest, originResponse []byte, originRequestHttps bool, ...) []byte
- func UrlToRequestPacket(method string, u string, originRequest []byte, originRequestHttps bool, ...) []byte
- func WebsocketFrameToData(frame *Frame) (data []byte)
- type CurlCommand
- type Frame
- type FrameReader
- type FrameWriter
- func (fw *FrameWriter) Flush() error
- func (fw *FrameWriter) WriteBinary(data []byte, mask bool, headerBytes ...byte) (err error)
- func (fw *FrameWriter) WriteFrame(frame *Frame, messageTypes ...int) (err error)
- func (fw *FrameWriter) WritePong(data []byte, mask bool) (err error)
- func (fw *FrameWriter) WriteRaw(raw []byte) (err error)
- func (fw *FrameWriter) WriteText(data []byte, mask bool, headerBytes ...byte) (err error)
- type LowhttpExecConfig
- type LowhttpOpt
- func WithBeforeDoRequest(h func([]byte) []byte) LowhttpOpt
- func WithContext(ctx context.Context) LowhttpOpt
- func WithDNSServers(servers []string) LowhttpOpt
- func WithETCHosts(hosts map[string]string) LowhttpOpt
- func WithFromPlugin(fromPlugin string) LowhttpOpt
- func WithGmTLS(b bool) LowhttpOpt
- func WithHost(host string) LowhttpOpt
- func WithHttp2(Http2 bool) LowhttpOpt
- func WithHttps(https bool) LowhttpOpt
- func WithJsRedirect(jsRedirect bool) LowhttpOpt
- func WithNoFixContentLength(noFixContentLength bool) LowhttpOpt
- func WithPacketBytes(packet []byte) LowhttpOpt
- func WithPort(port int) LowhttpOpt
- func WithProxy(proxy ...string) LowhttpOpt
- func WithRedirectHandler(redirectHandler func(bool, []byte, []byte) bool) LowhttpOpt
- func WithRedirectTimes(redirectTimes int) LowhttpOpt
- func WithRequest(packet any) LowhttpOpt
- func WithResponseCallback(h func(i *LowhttpResponse)) LowhttpOpt
- func WithRetryInStatusCode(sc []int) LowhttpOpt
- func WithRetryMaxWaitTime(retryMaxWaitTime time.Duration) LowhttpOpt
- func WithRetryNotInStatusCode(sc []int) LowhttpOpt
- func WithRetryTimes(retryTimes int) LowhttpOpt
- func WithRetryWaitTime(retryWaitTime time.Duration) LowhttpOpt
- func WithRuntimeId(runtimeId string) LowhttpOpt
- func WithSaveHTTPFlow(b bool) LowhttpOpt
- func WithSession(session interface{}) LowhttpOpt
- func WithSource(s string) LowhttpOpt
- func WithTimeout(timeout time.Duration) LowhttpOpt
- func WithTimeoutFloat(i float64) LowhttpOpt
- func WithVerifyCertificate(b bool) LowhttpOpt
- type LowhttpResponse
- type LowhttpTraceInfo
- type RedirectFlow
- type WebHookServer
- type WebsocketClient
- func (c *WebsocketClient) StartFromServer()
- func (c *WebsocketClient) Stop()
- func (c *WebsocketClient) Wait()
- func (c *WebsocketClient) Write(r []byte) error
- func (c *WebsocketClient) WriteBinary(r []byte) error
- func (c *WebsocketClient) WriteClose() error
- func (c *WebsocketClient) WritePong(r []byte) error
- func (c *WebsocketClient) WriteText(r []byte) error
- type WebsocketClientConfig
- type WebsocketClientOpt
- func WithWebsocketFromServerHandler(f func([]byte)) WebsocketClientOpt
- func WithWebsocketHost(t string) WebsocketClientOpt
- func WithWebsocketPort(t int) WebsocketClientOpt
- func WithWebsocketProxy(t string) WebsocketClientOpt
- func WithWebsocketTLS(t bool) WebsocketClientOpt
- func WithWebsocketTotalTimeout(t float64) WebsocketClientOpt
- func WithWebsocketWithContext(ctx context.Context) WebsocketClientOpt
Constants ¶
const ( CRLF = "\r\n" DoubleCRLF = "\r\n\r\n" )
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 )
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 ¶
var CookiejarPool sync.Map
var ReadHTTPRequestFromBufioReader = utils.ReadHTTPRequestFromBufioReader
var ReadHTTPRequestFromBytes = utils.ReadHTTPRequestFromBytes
var ReadHTTPResponseFromBufioReader = utils.ReadHTTPResponseFromBufioReader
var ReadHTTPResponseFromBytes = utils.ReadHTTPResponseFromBytes
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 AppendHTTPPacketCookie ¶ added in v1.2.3
func AppendHTTPPacketFormEncoded ¶ added in v1.2.4
func AppendHTTPPacketHeader ¶ added in v1.2.3
func AppendHTTPPacketPath ¶ added in v1.2.3
func AppendHTTPPacketPostParam ¶ added in v1.2.3
func AppendHTTPPacketQueryParam ¶ added in v1.2.3
func AppendHTTPPacketUploadFile ¶ added in v1.2.4
func CharsetToUTF8 ¶
func ContentEncodingDecode ¶
func CookieSafeQuoteString ¶ added in v1.2.2
func CookieSafeUnquoteString ¶ added in v1.2.2
func CookiesToString ¶
func CurlToHTTPRequest ¶
func DebugEchoServer ¶ added in v1.2.3
func DebugEchoServerContext ¶ added in v1.2.3
func DeleteHTTPPacketCookie ¶ added in v1.2.3
func DeleteHTTPPacketForm ¶ added in v1.2.4
func DeleteHTTPPacketHeader ¶ added in v1.2.3
func DeleteHTTPPacketPostParam ¶ added in v1.2.3
func DeleteHTTPPacketQueryParam ¶ added in v1.2.3
func DeletePacketEncoding ¶ added in v1.2.5
func ExtractBoundaryFromBody ¶
func ExtractBoundaryFromBody(raw interface{}) string
func FixHTTPPacketCRLF ¶
func FixHTTPRequest ¶ added in v1.2.6
func FixHTTPResponse ¶
FixHTTPResponse try its best to fix and present human-readable response
func FixRequestHostAndPort ¶ added in v1.2.3
func GetAllHTTPRequestPostParams ¶ added in v1.2.3
func GetAllHTTPRequestQueryParams ¶ added in v1.2.3
func GetCookiejar ¶
func GetHTTPPacketBody ¶ added in v1.2.3
func GetHTTPPacketContentType ¶ added in v1.2.3
func GetHTTPPacketCookie ¶ added in v1.2.3
func GetHTTPPacketCookieFirst ¶ added in v1.2.3
func GetHTTPPacketCookieValues ¶ added in v1.2.3
func GetHTTPPacketCookies ¶ added in v1.2.3
func GetHTTPPacketCookiesFull ¶ added in v1.2.3
func GetHTTPPacketFirstLine ¶ added in v1.2.4
func GetHTTPPacketHeader ¶ added in v1.2.3
func GetHTTPPacketHeaders ¶ added in v1.2.3
func GetHTTPPacketHeadersFull ¶ added in v1.2.3
func GetHTTPPacketJSONPath ¶ added in v1.2.3
func GetHTTPPacketJSONValue ¶ added in v1.2.3
func GetHTTPRequestPostParam ¶ added in v1.2.3
func GetHTTPRequestPostParamFull ¶ added in v1.2.3
func GetHTTPRequestQueryParam ¶ added in v1.2.3
func GetHTTPRequestQueryParamFull ¶ added in v1.2.3
func GetHostsFilePath ¶
func GetHostsFilePath() string
func GetOverrideContentType ¶
func GetStatusCodeFromResponse ¶ added in v1.2.3
func GetSystemEtcHosts ¶
func GetSystemHostByName ¶
func HTTPPacketForceChunked ¶
func HTTPRequestToHTTP2 ¶
func IsChunkedHeaderLine ¶ added in v1.2.3
func IsPermessageDeflate ¶
func MergeCookies ¶
func MergeUrlFromHTTPRequest ¶
func NewRequestPacketFromMethod ¶ added in v1.2.6
func ParseCookie ¶
func ReadHTTPPacketBodySize ¶
func RegisterSaveHTTPFlowHandler ¶
func RegisterSaveHTTPFlowHandler(h saveHTTPFlowHandler)
func RemoveCEHeaders ¶
func ReplaceAllHTTPPacketPostParams ¶ added in v1.2.4
func ReplaceAllHTTPPacketQueryParams ¶ added in v1.2.4
func ReplaceHTTPPacketBasicAuth ¶ added in v1.2.4
func ReplaceHTTPPacketBodyEx ¶
func ReplaceHTTPPacketBodyFast ¶ added in v1.2.3
func ReplaceHTTPPacketCookie ¶ added in v1.2.3
func ReplaceHTTPPacketFirstLine ¶ added in v1.2.3
func ReplaceHTTPPacketHeader ¶ added in v1.2.3
func ReplaceHTTPPacketHost ¶ added in v1.2.4
func ReplaceHTTPPacketMethod ¶ added in v1.2.4
func ReplaceHTTPPacketPath ¶ added in v1.2.3
func ReplaceHTTPPacketPostParam ¶ added in v1.2.3
func ReplaceHTTPPacketQueryParam ¶ added in v1.2.3
func ReplaceMIMEType ¶
func SaveResponse ¶
func SaveResponse(r *LowhttpResponse)
func ShouldSendReqContentLength ¶
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 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 ToUnquoteFuzzTag ¶
func TrimLeftHTTPPacket ¶
func TrimRightHTTPPacket ¶
func TrimSpaceHTTPPacket ¶
func UrlToGetRequestPacket ¶
func UrlToGetRequestPacketWithResponse ¶ added in v1.2.6
func UrlToGetRequestPacketWithResponse(u string, originRequest, originResponse []byte, originRequestHttps bool, cookies ...*http.Cookie) []byte
提取响应码以处理307和302的问题
func UrlToRequestPacket ¶ added in v1.2.3
func WebsocketFrameToData ¶
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 DataToWebsocketFrame ¶
func (*Frame) GetMaskingKey ¶
func (*Frame) RawPayloadData ¶
func (*Frame) SetMaskingKey ¶
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)
type LowhttpExecConfig ¶
type LowhttpExecConfig struct { Host string Port int Packet []byte VerifyCertificate bool 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 RuntimeId string FromPlugin string }
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
func WithVerifyCertificate ¶ added in v1.2.4
func WithVerifyCertificate(b bool) 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 MultiResponse bool }
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 RespRecord *LowhttpResponse }
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) WriteClose ¶ added in v1.2.4
func (c *WebsocketClient) WriteClose() error
func (*WebsocketClient) WritePong ¶
func (c *WebsocketClient) WritePong(r []byte) error
func (*WebsocketClient) WriteText ¶
func (c *WebsocketClient) WriteText(r []byte) error
type WebsocketClientConfig ¶
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
Source Files ¶
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. |