Documentation ¶
Overview ¶
Package http provides low level abstractions for sending/receiving raw http messages
Index ¶
- type Client
- type Connection
- type Destination
- type FTWConnection
- type Header
- func (h Header) Add(key, value string)
- func (h Header) AddStandard(dataSize int)
- func (h Header) Clone() Header
- func (h Header) Del(key string)
- func (h Header) Get(key string) string
- func (h Header) Set(key, value string)
- func (h Header) Value(key string) string
- func (h Header) Write(w io.Writer) error
- func (h Header) WriteBytes(b *bytes.Buffer) error
- type Request
- func (r *Request) AddHeader(name string, value string)
- func (r *Request) AddStandardHeaders(size int)
- func (r Request) Data() []byte
- func (r Request) Headers() Header
- func (r Request) RawData() []byte
- func (r *Request) SetAutoCompleteHeaders(value bool)
- func (r *Request) SetData(data []byte) error
- func (r *Request) SetHeaders(h Header)
- func (r *Request) SetRawData(raw []byte) error
- func (r Request) WithAutoCompleteHeaders() bool
- type RequestLine
- type Response
- type RoundTripTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.3.3
type Client struct { Transport *Connection Jar http.CookieJar Timeout time.Duration }
Client is the top level abstraction in http
func NewClient ¶ added in v0.3.3
func NewClient() *Client
NewClient initializes the http client, creating the cookiejar
func (*Client) GetRoundTripTime ¶ added in v0.3.3
func (c *Client) GetRoundTripTime() *RoundTripTime
GetRoundTripTime returns the time taken from the initial send till receiving the full response
func (*Client) NewConnection ¶ added in v0.3.3
func (c *Client) NewConnection(d Destination) error
NewConnection creates a new Connection based on a Destination
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is the type used for sending/receiving data
func (*Connection) GetRoundTripTime ¶ added in v0.2.0
func (c *Connection) GetRoundTripTime() *RoundTripTime
GetRoundTripTime will return the time since the request started and the response was parsed
func (*Connection) Request ¶
func (c *Connection) Request(request *Request) error
Request will use all the inputs and send a raw http request to the destination
func (*Connection) Response ¶
func (f *Connection) Response() (*Response, error)
Response reads the response sent by the WAF and return the corresponding struct It leverages the go stdlib for reading and parsing the response
type Destination ¶
type Destination struct { DestAddr string `default:"localhost"` Port int `default:"80"` Protocol string `default:"http"` }
Destination is the host, port and protocol to be used when connecting to a remote host
func DestinationFromString ¶ added in v0.2.0
func DestinationFromString(urlString string) *Destination
DestinationFromString create a Destination from String
type FTWConnection ¶
type FTWConnection interface { Request(*Request) Response(*Response) GetTrackedTime() *RoundTripTime // contains filtered or unexported methods }
FTWConnection is the interface method implement to send and receive data
type Header ¶
Header is a simplified version of headers, where there is only one header per key. The original golang stdlib uses a proper string slice to map this.
func (Header) Add ¶
Add adds the key, value pair to the header. It appends to any existing values associated with key.
func (Header) AddStandard ¶
AddStandard adds standard headers
func (Header) Get ¶
Get gets the first value associated with the given key. It is case insensitive; If there are no values associated with the key, Get returns "".
func (Header) Set ¶
Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key.
func (Header) Value ¶
Value returns the value associated with the given key. It is case insensitive;
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents a request No Defaults represents the previous "stop_magic" behavior
func NewRawRequest ¶ added in v0.2.0
NewRawRequest creates a new request, an initial request line, and headers
func NewRequest ¶ added in v0.2.0
func NewRequest(reqLine *RequestLine, h Header, data []byte, b bool) *Request
NewRequest creates a new request, an initial request line, and headers
func (*Request) AddStandardHeaders ¶
AddStandardHeaders adds standard headers to the request, if they don't exist
This will add Content-Length and the proper Content-Type
func (*Request) SetAutoCompleteHeaders ¶
SetAutoCompleteHeaders sets the value to the corresponding bool
func (*Request) SetHeaders ¶
SetHeaders sets the request headers
func (*Request) SetRawData ¶
SetRawData sets the data using raw bytes
When using raw data, no other checks will be done. You are responsible of creating the request line, all the headers, and body. You can use only one of raw or data.
func (Request) WithAutoCompleteHeaders ¶
WithAutoCompleteHeaders returns true when we need to add additional headers to complete the request
type RequestLine ¶
type RequestLine struct { Method string `default:"GET"` Version string `default:"HTTP/1.1"` URI string `default:"/"` }
RequestLine is the first line in the HTTP request dialog
func (RequestLine) ToString ¶
func (rl RequestLine) ToString() string
ToString converts the request line to string for sending it in the wire
type Response ¶
Response represents the http response received from the server/waf
func (*Response) GetBodyAsString ¶ added in v0.2.0
GetBodyAsString gives the response body as string, or nil if there was some error
type RoundTripTime ¶ added in v0.2.0
type RoundTripTime struct {
// contains filtered or unexported fields
}
RoundTripTime abstracts the time a transaction takes
func NewRoundTripTime ¶ added in v0.2.0
func NewRoundTripTime() *RoundTripTime
NewRoundTripTime initializes a roundtriptime struct
func (*RoundTripTime) RoundTripDuration ¶ added in v0.2.0
func (rtt *RoundTripTime) RoundTripDuration() time.Duration
RoundTripDuration gives the total time spent in this roundtrip
func (*RoundTripTime) StartTime ¶ added in v0.2.0
func (rtt *RoundTripTime) StartTime() time.Time
StartTime returns the time when this round trip started
func (*RoundTripTime) StartTracking ¶ added in v0.2.0
func (rtt *RoundTripTime) StartTracking()
StartTracking sets the initial time to Now
func (*RoundTripTime) StopTime ¶ added in v0.2.0
func (rtt *RoundTripTime) StopTime() time.Time
StopTime returns the time when this round trip was stopped
func (*RoundTripTime) StopTracking ¶ added in v0.2.0
func (rtt *RoundTripTime) StopTracking()
StopTracking sets the finish time to Now