Documentation ¶
Index ¶
- Constants
- Variables
- func ASCIIToUpper(str string) []byte
- func AddAndValidateExtraHeader(h string) error
- 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 EchoServer(port int, debugPath string)
- 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 TestHTTP(t int)
- type BasicClient
- type Client
- type Fetcher
- type HTTPRunnerOptions
- type HTTPRunnerResults
Constants ¶
const (
Version = "v0.2.8"
)
Version is the fortio package version (TODO:auto gen/extract).
Variables ¶
var ( // BufferSizeKb size of the buffer (max data) for optimized client in kilobytes defaults to 32k. BufferSizeKb = 32 // 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 AddAndValidateExtraHeader ¶
AddAndValidateExtraHeader collects extra headers (see main.go for example).
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 EchoServer ¶
EchoServer starts a debug / echo http server on the given port.
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
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 ¶
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.
type HTTPRunnerOptions ¶
type HTTPRunnerOptions struct { periodic.RunnerOptions URL string 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 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 Sizes *stats.Histogram HeaderSizes *stats.Histogram // 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.