Documentation ¶
Index ¶
- Variables
- func ASCIIToUpper(str string) []byte
- func DebugHandler(w http.ResponseWriter, r *http.Request)
- func DebugSummary(buf []byte, max int) string
- func DynamicHTTPServer(secure bool) int
- func EchoHandler(w http.ResponseWriter, r *http.Request)
- func EscapeBytes(buf []byte) string
- func FetchURL(url string) (int, []byte, int)
- func FoldFind(haystack []byte, needle []byte) (bool, int)
- func ParseChunkSize(inp []byte) (int, int)
- func ParseDecimal(inp []byte) int
- func RoundDuration(d time.Duration) time.Duration
- func Serve(port int, debugPath string)
- type BasicClient
- type Client
- type Fetcher
- type HTTPOptions
- type HTTPRunnerOptions
- type HTTPRunnerResults
Constants ¶
This section is empty.
Variables ¶
var ( // BufferSizeKb size of the buffer (max data) for optimized client in kilobytes defaults to 32k. BufferSizeKb = 128 // CheckConnectionClosedHeader indicates whether to check for server side connection closed headers. CheckConnectionClosedHeader = false )
var ( // EchoRequests is the number of request received. Only updated in Debug mode. EchoRequests int64 )
Functions ¶
func ASCIIToUpper ¶
ASCIIToUpper returns a byte array equal to the input string but in lowercase. Only wotks for ASCII, not meant for unicode.
func DebugHandler ¶
func DebugHandler(w http.ResponseWriter, r *http.Request)
DebugHandler returns debug/useful info to http client.
func DebugSummary ¶
DebugSummary returns a string with the size and escaped first max/2 and last max/2 bytes of a buffer (or the whole escaped buffer if small enough).
func DynamicHTTPServer ¶
DynamicHTTPServer listens on an available port, sets up an http or https (when secure is true) server on it and returns the listening port.
func EchoHandler ¶
func EchoHandler(w http.ResponseWriter, r *http.Request)
EchoHandler is an http server handler echoing back the input.
func EscapeBytes ¶
EscapeBytes returns printable string. Same as %q format without the surrounding/extra "".
func FetchURL ¶
FetchURL fetches URL content and does error handling/logging. Version not reusing the client.
func FoldFind ¶
FoldFind searches the bytes assuming ascii, ignoring the lowercase bit for testing. Not intended to work with unicode, meant for http headers and to be fast (see benchmark in test file).
func ParseChunkSize ¶
ParseChunkSize extracts the chunk size and consumes the line. Returns the offset of the data and the size of the chunk, 0, -1 when not found.
func ParseDecimal ¶
ParseDecimal extracts the first positive integer number from the input. spaces are ignored. any character that isn't a digit cause the parsing to stop
func RoundDuration ¶ added in v0.3.7
RoundDuration rounds to 10th of second. Only for positive durations. TODO: switch to Duration.Round once switched to go 1.9
Types ¶
type BasicClient ¶
type BasicClient struct {
// contains filtered or unexported fields
}
BasicClient is a fast, lockfree single purpose http 1.0/1.1 client.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client object for making repeated requests of the same URL using the same http client (net/http)
type Fetcher ¶
type Fetcher interface { // Fetch returns http code, data, offset of body (for client which returns // headers) Fetch() (int, []byte, int) }
Fetcher is the Url content fetcher that the different client implements.
func NewBasicClient ¶
func NewBasicClient(o *HTTPOptions) Fetcher
NewBasicClient makes a basic, efficient http 1.0/1.1 client. This function itself doesn't need to be super efficient as it is created at the beginning and then reused many times.
func NewClient ¶ added in v0.4.2
func NewClient(o *HTTPOptions) Fetcher
NewClient creates either a standard or fast client (depending on the DisableFastClient flag)
func NewStdClient ¶
func NewStdClient(o *HTTPOptions) Fetcher
NewStdClient creates a client object that wraps the net/http standard client.
type HTTPOptions ¶ added in v0.4.2
type HTTPOptions struct { URL string NumConnections int // num connections (for std client) Compression bool // defaults to no compression, only used by std client DisableFastClient bool // defaults to fast client HTTP10 bool // defaults to http1.1 DisableKeepAlive bool // so default is keep alive AllowHalfClose bool // if not keepalive, whether to half close after request // contains filtered or unexported fields }
HTTPOptions holds the common options of both http clients and the headers.
func NewHTTPOptions ¶ added in v0.4.2
func NewHTTPOptions(url string) *HTTPOptions
NewHTTPOptions creates and initialize a HTTPOptions object.
func (*HTTPOptions) AddAndValidateExtraHeader ¶ added in v0.4.2
func (h *HTTPOptions) AddAndValidateExtraHeader(hdr string) error
AddAndValidateExtraHeader collects extra headers (see main.go for example).
func (*HTTPOptions) GetHeaders ¶ added in v0.4.2
func (h *HTTPOptions) GetHeaders() http.Header
GetHeaders returns the current set of headers.
func (*HTTPOptions) Init ¶ added in v0.4.2
func (h *HTTPOptions) Init(url string) *HTTPOptions
Init initializes the headers in an HTTPOptions (User-Agent).
func (*HTTPOptions) ResetHeaders ¶ added in v0.4.2
func (h *HTTPOptions) ResetHeaders()
ResetHeaders resets all the headers, including the User-Agent one.
type HTTPRunnerOptions ¶
type HTTPRunnerOptions struct { periodic.RunnerOptions HTTPOptions // Need to call Init() to initialize Profiler string // file to save profiles to. defaults to no profiling }
HTTPRunnerOptions includes the base RunnerOptions plus http specific options.
type HTTPRunnerResults ¶
type HTTPRunnerResults struct { periodic.RunnerResults RetCodes map[int]int64 // exported result Sizes *stats.HistogramData HeaderSizes *stats.HistogramData URL string // contains filtered or unexported fields }
HTTPRunnerResults is the aggregated result of an HTTPRunner. Also is the internal type used per thread/goroutine.
func RunHTTPTest ¶
func RunHTTPTest(o *HTTPRunnerOptions) (*HTTPRunnerResults, error)
RunHTTPTest runs an http test and returns the aggregated stats.
func (*HTTPRunnerResults) Run ¶ added in v0.4.2
func (httpstate *HTTPRunnerResults) Run(t int)
Run tests http request fetching. Main call being run at the target QPS. To be set as the Function in RunnerOptions.