Documentation ¶
Index ¶
- Variables
- func BuildErrorResponse(outreq *http.Request, err error) *http.Response
- func Uuid() string
- type HttpApplication
- type HttpFlow
- type HttpMitmProxy
- type PersistConn
- type ProxyTransport
- func (t *ProxyTransport) ClientClose(remote string)
- func (t *ProxyTransport) GetConnection(req *http.Request) (*PersistConn, error)
- func (t *ProxyTransport) NewConnection(req *http.Request, pconn *PersistConn) error
- func (t *ProxyTransport) PutConnection(pconn *PersistConn) error
- func (t *ProxyTransport) ReadResponse(pconn *PersistConn, req *http.Request) (resp *http.Response, err error)
- func (t *ProxyTransport) RoundTrip(req *http.Request) (*http.Response, error)
- func (t *ProxyTransport) Write(pconn *PersistConn, req *http.Request, src []byte) (int, error)
- func (t *ProxyTransport) WriteHeader(pconn *PersistConn, req *http.Request) error
- type StreamingTransport
Constants ¶
This section is empty.
Variables ¶
var ErrHttpBadRequest = errors.New("Bad Request")
var ErrHttpForbiddenRequest = errors.New("Forbidden")
* Errors that the HttpApplication handlers return on failure. * This would then result in appropriate Http Response being * sent to the client
var ErrRequestShortWrite = errors.New("Request Short Write")
var ErrResponseShortWrite = errors.New("Response Short Write")
ErrResponseShortWrite means that a write accepted fewer bytes than requested but failed to return an explicit error.
var ProxyErrMissingHost = errors.New("proxy: Request with no Host or URL set")
Functions ¶
Types ¶
type HttpApplication ¶
type HttpApplication interface { RequestDataHandler(flow *HttpFlow, data []byte) ([]byte, error) ResponseDataHandler(flow *HttpFlow, data []byte) ([]byte, error) RequestHandler(flow *HttpFlow) error ResponseHandler(flow *HttpFlow) error StreamedRequestDataHandler(flow *HttpFlow, buf []byte, last_chunk bool) ([]byte, error) StreamedResponseDataHandler(flow *HttpFlow, buf []byte, last_chunk bool) ([]byte, error) FailureHandler(flow *HttpFlow) }
HTTP proxy application This interface encapsulates the methods that the HTTP processing application needs to implement to use the mitm proxy service - a handler to process HTTP Requests - a handler to process HTTP Responses
type HttpMitmProxy ¶
type HttpMitmProxy struct { // The transport used to perform proxy requests. // If nil, http.DefaultTransport is used Transport StreamingTransport // BufferPool specifies a buffer pool to get byte slices for use by // io.CopyBuffer when copying HTTP request and response bodies BufferPool *bpool.BytePool ChunkSize int64 // contains filtered or unexported fields }
* HTTP mitm proxy
func NewHttpMitmProxy ¶
func NewHttpMitmProxy(addr string, app HttpApplication, sslCertFile, sslKeyFile string) (*HttpMitmProxy, error)
func (*HttpMitmProxy) ServeHTTP ¶
func (p *HttpMitmProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*HttpMitmProxy) Start ¶
func (p *HttpMitmProxy) Start() error
type PersistConn ¶
type PersistConn struct {
// contains filtered or unexported fields
}
type ProxyTransport ¶
type ProxyTransport struct {
// contains filtered or unexported fields
}
func GetDefaultTransport ¶
func GetDefaultTransport() *ProxyTransport
func (*ProxyTransport) ClientClose ¶
func (t *ProxyTransport) ClientClose(remote string)
Called by the proxy to notify that the frontend client has closed its connection. The transport implemenation can use this to cleanup its state, if any
func (*ProxyTransport) GetConnection ¶
func (t *ProxyTransport) GetConnection(req *http.Request) (*PersistConn, error)
func (*ProxyTransport) NewConnection ¶
func (t *ProxyTransport) NewConnection(req *http.Request, pconn *PersistConn) error
func (*ProxyTransport) PutConnection ¶
func (t *ProxyTransport) PutConnection(pconn *PersistConn) error
return the connection back to the pool.
func (*ProxyTransport) ReadResponse ¶
func (t *ProxyTransport) ReadResponse(pconn *PersistConn, req *http.Request) (resp *http.Response, err error)
func (*ProxyTransport) Write ¶
func (t *ProxyTransport) Write(pconn *PersistConn, req *http.Request, src []byte) (int, error)
func (*ProxyTransport) WriteHeader ¶
func (t *ProxyTransport) WriteHeader(pconn *PersistConn, req *http.Request) error
type StreamingTransport ¶
type StreamingTransport interface { // A StreamingTransport provides support to stream HTTP requests // and responses to a server, optionally re-using connections // to ship multiple http transactions // // It should not attempt to intrepret the response or modify the // request. // The Request's URL and Header fields are expected to be initialized GetConnection(req *http.Request) (*PersistConn, error) PutConnection(pconn *PersistConn) error WriteHeader(pconn *PersistConn, req *http.Request) error Write(pconn *PersistConn, req *http.Request, src []byte) (int, error) ReadResponse(pconn *PersistConn, req *http.Request) (resp *http.Response, err error) ClientClose(remote string) }
A StreamingTransport must be safe for concurrent use by multiple goroutines.