Documentation
¶
Overview ¶
Package recorder 记录http transaction
Index ¶
- func IsBinaryBody(contentType string) bool
- type Body
- type CertCache
- type Interceptor
- type Output
- type Recorder
- func (r *Recorder) Auth(ctx *goproxy.Context, rw http.ResponseWriter)
- func (r *Recorder) BeforeRequest(ctx *goproxy.Context)
- func (r *Recorder) BeforeResponse(ctx *goproxy.Context, resp *http.Response, err error)
- func (r *Recorder) Connect(ctx *goproxy.Context, rw http.ResponseWriter)
- func (r *Recorder) DoRequest(req *http.Request)
- func (r *Recorder) ErrorLog(err error)
- func (r *Recorder) Finish(ctx *goproxy.Context)
- func (r *Recorder) ParentProxy(req *http.Request) (*url.URL, error)
- func (r *Recorder) Replay(txId string) error
- func (r *Recorder) SetInterceptor(i Interceptor)
- func (r *Recorder) SetOutput(o Output)
- func (r *Recorder) SetProxy(p *goproxy.Proxy)
- func (r *Recorder) SetStorage(s Storage)
- func (r *Recorder) Storage() Storage
- type Request
- type Response
- type Storage
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Body ¶
type Body struct {
IsBinary bool `json:"is_binary"`
Len int `json:"len"`
ContentType string `json:"content_type"`
Content []byte `json:"content"`
}
Body HTTP请求、响应Body
type Interceptor ¶
type Interceptor interface {
// Connect 收到客户端连接, 自定义response返回, 只支持HTTP
Connect(ctx *goproxy.Context, rw http.ResponseWriter)
// BeforeRequest 请求发送前, 修改request
BeforeRequest(ctx *goproxy.Context)
// BeforeResponse 响应发送前, 修改response
BeforeResponse(ctx *goproxy.Context, resp *http.Response, err error)
}
Interceptor 拦截器
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder 记录http transaction
func (*Recorder) Auth ¶
func (r *Recorder) Auth(ctx *goproxy.Context, rw http.ResponseWriter)
Auth 代理身份认证
func (*Recorder) BeforeRequest ¶
BeforeRequest 请求发送前处理
func (*Recorder) BeforeResponse ¶
BeforeResponse 响应发送前处理
func (*Recorder) Connect ¶
func (r *Recorder) Connect(ctx *goproxy.Context, rw http.ResponseWriter)
Connect 收到客户端连接
func (*Recorder) ParentProxy ¶
ParentProxy 设置上级代理
func (*Recorder) SetInterceptor ¶
func (r *Recorder) SetInterceptor(i Interceptor)
SetInterceptor 设置拦截器
type Request ¶
type Request struct {
// Proto HTTP协议版本
Proto string `json:"proto"`
// Method 请求方法
Method string `json:"method"`
// Scheme 请求协议
Scheme string `json:"scheme"`
// Host 请求主机名
Host string `json:"host"`
// Path 请求path
Path string `json:"path"`
// QueryParam URL参数
QueryParam string `json:"query_param"`
// URL 完整URL
URL string `json:"url"`
// Header 请求Header
Header http.Header `json:"header"`
// Body 请求body
Body *Body `json:"body"`
}
Request HTTP请求
type Response ¶
type Response struct {
// Proto 响应协议
Proto string `json:"proto"`
// Status 状态状态
Status string `json:"status"`
// StatusCode 响应码
StatusCode int `json:"status_code"`
// Header 响应Header
Header http.Header `json:"header"`
// Body 响应Body
Body *Body `json:"body"`
// Err 错误信息
Err string `json:"err"`
}
Response HTTP响应
func NewResponse ¶
func NewResponse() *Response
type Storage ¶
type Storage interface {
Get(txId string) (*Transaction, error)
Put(*Transaction) error
}
Storage 存取transaction接口
type Transaction ¶
type Transaction struct {
// Id 唯一id
Id string `json:"id"`
// Req 请求
Req *Request `json:"request"`
// Resp 响应
Resp *Response `json:"response"`
// ClientIP 客户端IP
ClientIP string `json:"client_ip"`
// ServerIP 服务端IP
ServerIP string `json:"server_ip"`
// StartTime 开始时间
StartTime time.Time `json:"start_time"`
// Duration 持续时间
Duration time.Duration `json:"duration"`
}
Transaction HTTP事务
func (*Transaction) DumpRequest ¶
func (tx *Transaction) DumpRequest(req *http.Request)
DumpRequest 提取request
func (*Transaction) DumpResponse ¶
func (tx *Transaction) DumpResponse(resp *http.Response, e error)
DumpRequest 提取response
Source Files
¶
Click to show internal directories.
Click to hide internal directories.