Documentation ¶
Overview ¶
Package intercept is meant to handle all the interception of requests and responses, including stopping and waiting for edited payloads. Every request going through the proxy is parsed and added to the Status by this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var HopByHopHeaders = []string{
"Content-Encoding",
"Connection",
"TE",
"HTTP2-Settings",
"Keep-Alive",
"Proxy-Authenticate",
"Proxy-Connection",
"Proxy-Authorization",
"Trailer",
"Upgrade",
"Transfer-Encoding",
"Alternate-Protocol",
"X-Forwarded-For",
"Proxy-Connection",
}
HopByHopHeaders is a list of all the HTTP headers that are stripped away by the proxy
var RequestQueue chan *pendingRequest
RequestQueue represents the queue of requests that have been intercepted
var ResponseQueue chan *pendingResponse
ResponseQueue represents the queue of the response to requests that have been intercepted
Functions ¶
func GenerateResponse ¶
GenerateResponse creates a response with a given title, content and status code. This can be used for example to provide responses when a request is dropped and do not leave the client hanging.
func MainLoop ¶
func MainLoop()
MainLoop is the core of the interceptor. In order for the normal lifecycle program to work this should always be started. It starts the goroutine that waits for new requests and response that have been intercepted and takes action based on current configuration.
func StatusDump ¶
func StatusDump(status *History)
StatusDump dumps the status in the log. This is only meant for debug purposes.
Types ¶
type History ¶
type History struct { sync.RWMutex `json:"-"` //Remove count, use it only for serialization Count int ReqResps []*ReqResp }
History is used to represent all the req/resp that went through the proxy FIXME!!! implement high-level methods!!! FIXME make the fields private and create a dummy object to transmit this
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is a struct that respects the net.RoundTripper interface and just wraps the original http.RoundTripper
type ReqResp ¶
type ReqResp struct { //Unique ID in the history ID int //Meta Data about both Req and Resp MetaData *apis.ReqRespMetaData //Original Request RawReq []byte //Original Response RawRes []byte //Edited Request RawEditedReq []byte //Edited Response RawEditedRes []byte }
ReqResp represents an item of the proxy history TODO methods to parse req-resp TODO create a test that fails if this is different from apis.ReqResp