httpx

package
v0.1.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeRequest is an HTTP request.
	TypeRequest = '0'
	// TypeResponse is an HTTP response.
	TypeResponse = '1'
)

Variables

This section is empty.

Functions

func NewHAR

func NewHAR(ctx core.Context) (core.OutputFormat, error)

NewHAR creates a mew HAR format.

func NewInputFormat

func NewInputFormat(ctx core.Context) (core.InputFormat, error)

NewInputFormat creates an HTTP input formatter.

func NewMetricsOutput

func NewMetricsOutput() *flow.Output

NewMetricsOutput creates a new *output.Pipe for calculating HTTP metrics

func NewOutputFormat

func NewOutputFormat(ctx core.Context) (core.OutputFormat, error)

NewOutputFormat creates an HTTP output format.

Types

type Correlator

type Correlator struct {
	Messages  chan Message
	Exchanges chan *Request
	// contains filtered or unexported fields
}

Correlator aggregates HTTP requests and responses and creates a full exchange once a request's response is recieved. Requests that live longer than the timeout without a corresponding response are considered as not having a response and returned as-is.

func NewCorrelator

func NewCorrelator(timeout time.Duration) *Correlator

NewCorrelator creates a new correlator.

func (*Correlator) Start

func (c *Correlator) Start(ctx core.Context)

Start starts the correlator. Goroutines are now spawned internally within this method.

type HAR

type HAR struct {
	// contains filtered or unexported fields
}

HAR is an HTTP Archive. https://w3c.github.io/web-performance/specs/HAR/Overview.html http://www.softwareishard.com/blog/har-12-spec/

func (*HAR) Complete

func (h *HAR) Complete() <-chan struct{}

Complete returns a completion channel.

func (*HAR) In

func (h *HAR) In() chan<- interface{}

In returns the input channel.

func (*HAR) Init

func (h *HAR) Init(ctx core.Context, w io.Writer)

Init initializes the HAR sink.

type Message

type Message interface {
	GetConnectionID() string
	GetExchangeID() string
	SetCreated(time.Time)
	SetSessionID(string)
}

Message is an HTTP message.

type MessageType

type MessageType byte

MessageType is the type of an HTTP message.

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics is a format that calculates HTTP metrics for Prometheus monitoring Note that this format does not modify data passing through it, it merely extracts metrics. Also note that this is a "dead end" format: its output io.Reader is never updated and remains empty.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new Metrics format.

func (*Metrics) Complete

func (m *Metrics) Complete() <-chan struct{}

Complete returns a completion channel.

func (*Metrics) In

func (m *Metrics) In() chan<- interface{}

In returns the input channel.

func (*Metrics) Init

func (m *Metrics) Init(ctx core.Context, _ io.Writer)

Init initializes the metrics format and registers the metrics with Prometheus

type Request

type Request struct {
	ConnectionID     string         `json:"connection_id,omitempty"`
	ExchangeID       string         `json:"exchange_id,omitempty"`
	Created          time.Time      `json:"created,omitempty"`
	Method           string         `json:"method,omitempty"`
	URL              *url.URL       `json:"url,omitempty"`
	Proto            string         `json:"proto,omitempty"`
	ProtoMajor       int            `json:"proto_major,omitempty"`
	ProtoMinor       int            `json:"proto_minor,omitempty"`
	Header           http.Header    `json:"header,omitempty"`
	MimeType         string         `json:"mimetype,omitempty"`
	PostForm         url.Values     `json:"postform,omitempty"`
	Cookies          []*http.Cookie `json:"cookies,omitempty"`
	Body             string         `json:"body,omitempty"`
	ContentLength    int64          `json:"content_length,omitempty"`
	TransferEncoding []string       `json:"transfer_encoding,omitempty"`
	Host             string         `json:"host,omitempty"`
	Trailer          http.Header    `json:"trailer,omitempty"`
	RemoteAddr       string         `json:"remote_addr,omitempty"`
	RequestURI       string         `json:"request_uri,omitempty"`
	Response         *Response      `json:"response,omitempty"`
	SessionID        string         `json:"session_id,omitempty"`
	ClientAddr       string         `json:"client_addr,omitempty"`
	ClientPort       string         `json:"client_port,omitempty"`
	ServerAddr       string         `json:"server_addr,omitempty"`
	ServerPort       string         `json:"server_port,omitempty"`
}

Request represents an HTTP request.

func NewRequest

func NewRequest(b *bufio.Reader, connectionID string, exchangeID string, m *core.Meta) (*Request, error)

NewRequest creates a new Request.

func (*Request) GetConnectionID

func (r *Request) GetConnectionID() string

GetConnectionID gets a connection ID.

func (*Request) GetExchangeID

func (r *Request) GetExchangeID() string

GetExchangeID gets an exchange ID.

func (*Request) Kind

func (r *Request) Kind() envelope.Kind

Kind gets an envelope kind for a Request.

func (*Request) SetCreated

func (r *Request) SetCreated(created time.Time)

SetCreated sets the created timestamp

func (*Request) SetSessionID

func (r *Request) SetSessionID(id string)

SetSessionID sets the session ID

func (*Request) StdRequest

func (r *Request) StdRequest() *http.Request

StdRequest converts a Request into an *http.Request.

type Response

type Response struct {
	ConnectionID     string         `json:"connection_id,omitempty"`
	ExchangeID       string         `json:"exchange_id"`
	Created          time.Time      `json:"created,omitempty"`
	Status           string         `json:"status,omitempty"`
	StatusCode       int            `json:"status_code,omitempty"`
	Proto            string         `json:"proto,omitempty"`
	ProtoMajor       int            `json:"proto_major,omitempty"`
	ProtoMinor       int            `json:"proto_minor,omitempty"`
	Header           http.Header    `json:"header,omitempty"`
	Cookies          []*http.Cookie `json:"cookies,omitempty"`
	Body             string         `json:"body,omitempty"`
	ContentLength    int64          `json:"content_length,omitempty"`
	TransferEncoding []string       `json:"transfer_encoding,omitempty"`
	Close            bool           `json:"close,omitempty"`
	Uncompressed     bool           `json:"uncompressed,omitempty"`
	Trailer          http.Header    `json:"trailer,omitempty"`
	SessionID        string         `json:"session_id,omitempty"`
	Location         string         `json:"location,omitempty"`
	ClientAddr       string         `json:"client_addr,omitempty"`
	ClientPort       string         `json:"client_port,omitempty"`
	ServerAddr       string         `json:"server_addr,omitempty"`
	ServerPort       string         `json:"server_port,omitempty"`
}

Response represents an HTTP response.

func NewResponse

func NewResponse(b *bufio.Reader, connectionID, exchangeID string, m *core.Meta) (*Response, error)

NewResponse creates a new Response.

func (*Response) GetConnectionID

func (r *Response) GetConnectionID() string

GetConnectionID gets a connection ID.

func (*Response) GetExchangeID

func (r *Response) GetExchangeID() string

GetExchangeID gets an exchange ID.

func (*Response) Kind

func (r *Response) Kind() envelope.Kind

Kind gets an envelope kind for a Response.

func (*Response) SetCreated

func (r *Response) SetCreated(created time.Time)

SetCreated sets the created timestamp

func (*Response) SetSessionID

func (r *Response) SetSessionID(id string)

SetSessionID sets the session ID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL