request

package
v0.0.0-...-eab4402 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package request provides types and functions to describe executed requests and their attributes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FinishedRequest

type FinishedRequest struct {
	// The URL this request was executed for
	URL string

	// Any error received during the request
	Error error

	// The HTTP status code of the request
	StatusCode int

	// The start time
	Started time.Time

	// The time the request has finished
	Finished time.Time

	// The content length
	ContentLength int64

	// HTTP response headers received
	Header Header

	// Stats whether this request reused an established TCP connection via HTTP keep alive or created a fresh one
	Reused bool

	// Timing details for this request
	TimingDetails TimingDetails
}

FinishedRequest represents a single sample of an HTTP(S) request. It includes status and timing information

func ExecuteGet

func ExecuteGet(url string, header map[string]string, client *http.Client) *FinishedRequest

ExecuteGet executes a HTTP(S) GET Request for the given URL and returns the result as a Request

func (*FinishedRequest) ContentType

func (r *FinishedRequest) ContentType() string

ContentType is a convenience method that returns the content type header value

func (*FinishedRequest) IsError

func (r *FinishedRequest) IsError() bool

IsError returns whether this sample was successful or not

func (*FinishedRequest) TotalTime

func (r *FinishedRequest) TotalTime() time.Duration

TotalTime returns the total time needed to execute the request

type Header map[string][]string

Header contains the HTTP response headers for a request Header names are canonicalized, i.e. "Content-Length"

func (Header) String

func (h Header) String() string

type TimingDetails

type TimingDetails struct {
	// The total time needed to execute the request
	TotalTime time.Duration

	// The time needed to resolve the host name via DNS
	DNSTime time.Duration

	// The time needed to establish a TCP connection
	TCPConnectTime time.Duration

	// The time needed to perform the TLS handshake
	TLSTime time.Duration

	// The time needed to write the request
	SendRequestTime time.Duration

	// The time waited for the first response byte
	TimeToFirstByte time.Duration

	// The time needed to transfer all content
	ContentTransferTime time.Duration
}

Jump to

Keyboard shortcuts

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