Documentation ¶
Overview ¶
Package http implements the k6/http js module for k6. That module is used to make http requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBatchForbiddenInInitContext = common.NewInitContextError(
"Using batch in the init context is not supported")
ErrBatchForbiddenInInitContext is used when batch was made in the init context
var ErrHTTPForbiddenInInitContext = common.NewInitContextError(
"Making http requests in the init context is not supported")
ErrHTTPForbiddenInInitContext is used when a http requests was made in the init context
var ErrJarForbiddenInInitContext = common.NewInitContextError("Making cookie jars in the init context is not supported")
ErrJarForbiddenInInitContext is used when a cookie jar was made in the init context TODO: unexport this? there's no reason for this to be exported
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.36.0
type Client struct {
// contains filtered or unexported fields
}
Client represents a stand-alone HTTP client.
TODO: move to its own file
func (*Client) Batch ¶ added in v0.36.0
Batch makes multiple simultaneous HTTP requests. The provideds reqsV should be an array of request objects. Batch returns an array of responses and/or error
func (*Client) Request ¶ added in v0.36.0
Request makes an http request of the provided `method` and returns a corresponding response by taking sobek.Values as arguments
func (*Client) SetResponseCallback ¶ added in v0.36.0
SetResponseCallback sets the responseCallback to the value provided. Supported values are expectedStatuses object or a `null` which means that metrics shouldn't be tagged as failed and `http_req_failed` should not be emitted - the behaviour previous to this
type CookieJar ¶ added in v0.36.0
type CookieJar struct { // js is to make it not be accessible from inside Sobek/js, the json is // for when it is returned from setup(). Jar *cookiejar.Jar `js:"-" json:"-"` // contains filtered or unexported fields }
CookieJar is cookiejar.Jar wrapper to be used in js scripts
func (CookieJar) CookiesForURL ¶ added in v0.36.0
CookiesForURL return the cookies for a given url as a map of key and values
type FileData ¶ added in v0.20.0
FileData represents a binary file requiring multipart request encoding
type ModuleInstance ¶ added in v0.36.0
type ModuleInstance struct {
// contains filtered or unexported fields
}
ModuleInstance represents an instance of the HTTP module for every VU.
func (*ModuleInstance) Exports ¶ added in v0.36.0
func (mi *ModuleInstance) Exports() modules.Exports
Exports returns the JS values this module exports.
type Response ¶ added in v0.24.0
Response is a representation of an HTTP response to be returned to the Sobek VM
func (*Response) ClickLink ¶ added in v0.24.0
ClickLink parses the body as an html, looks for a link and than makes a request as if the link was clicked
type RootModule ¶ added in v0.36.0
type RootModule struct{}
RootModule is the global module object type. It is instantiated once per test run and will be used to create HTTP module instances for each VU.
TODO: add sync.Once for all of the deprecation warnings we might want to do for the old k6/http APIs here, so they are shown only once in a test run.
func (*RootModule) NewModuleInstance ¶ added in v0.36.0
func (r *RootModule) NewModuleInstance(vu modules.VU) modules.Instance
NewModuleInstance returns an HTTP module instance for each VU.