Documentation

Index

Constants

View Source
const (
	HTTP_METHOD_GET     = "GET"
	HTTP_METHOD_POST    = "POST"
	HTTP_METHOD_PUT     = "PUT"
	HTTP_METHOD_DELETE  = "DELETE"
	HTTP_METHOD_HEAD    = "HEAD"
	HTTP_METHOD_PATCH   = "PATCH"
	HTTP_METHOD_OPTIONS = "OPTIONS"
)

Variables

View Source
var ErrBatchForbiddenInInitContext = common.NewInitContextError("Using batch in the init context is not supported")

    ErrBatchForbiddenInInitContext is used when batch was made in the init context

    View Source
    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

      View Source
      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

        Functions

        func ToURL

        func ToURL(u interface{}) (httpext.URL, error)

          ToURL tries to convert anything passed to it to a k6 URL struct

          Types

          type FileData

          type FileData struct {
          	Data        []byte
          	Filename    string
          	ContentType string
          }

            FileData represents a binary file requiring multipart request encoding

            type HTTP

            type HTTP struct {
            	SSL_3_0                            string `js:"SSL_3_0"`
            	TLS_1_0                            string `js:"TLS_1_0"`
            	TLS_1_1                            string `js:"TLS_1_1"`
            	TLS_1_2                            string `js:"TLS_1_2"`
            	TLS_1_3                            string `js:"TLS_1_3"`
            	OCSP_STATUS_GOOD                   string `js:"OCSP_STATUS_GOOD"`
            	OCSP_STATUS_REVOKED                string `js:"OCSP_STATUS_REVOKED"`
            	OCSP_STATUS_SERVER_FAILED          string `js:"OCSP_STATUS_SERVER_FAILED"`
            	OCSP_STATUS_UNKNOWN                string `js:"OCSP_STATUS_UNKNOWN"`
            	OCSP_REASON_UNSPECIFIED            string `js:"OCSP_REASON_UNSPECIFIED"`
            	OCSP_REASON_KEY_COMPROMISE         string `js:"OCSP_REASON_KEY_COMPROMISE"`
            	OCSP_REASON_CA_COMPROMISE          string `js:"OCSP_REASON_CA_COMPROMISE"`
            	OCSP_REASON_AFFILIATION_CHANGED    string `js:"OCSP_REASON_AFFILIATION_CHANGED"`
            	OCSP_REASON_SUPERSEDED             string `js:"OCSP_REASON_SUPERSEDED"`
            	OCSP_REASON_CESSATION_OF_OPERATION string `js:"OCSP_REASON_CESSATION_OF_OPERATION"`
            	OCSP_REASON_CERTIFICATE_HOLD       string `js:"OCSP_REASON_CERTIFICATE_HOLD"`
            	OCSP_REASON_REMOVE_FROM_CRL        string `js:"OCSP_REASON_REMOVE_FROM_CRL"`
            	OCSP_REASON_PRIVILEGE_WITHDRAWN    string `js:"OCSP_REASON_PRIVILEGE_WITHDRAWN"`
            	OCSP_REASON_AA_COMPROMISE          string `js:"OCSP_REASON_AA_COMPROMISE"`
            }

              nolint: golint

              func New

              func New() *HTTP

              func (*HTTP) Batch

              func (h *HTTP) Batch(ctx context.Context, reqsV goja.Value) (goja.Value, error)

                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 (*HTTP) CookieJar

                func (*HTTP) CookieJar(ctx context.Context) (*HTTPCookieJar, error)

                func (*HTTP) Del

                func (h *HTTP) Del(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                  Del makes an HTTP DELETE and returns a corresponding response by taking goja.Values as arguments

                  func (*HTTP) File

                  func (h *HTTP) File(data []byte, args ...string) FileData

                    File returns a FileData parameter

                    func (*HTTP) Get

                    func (h *HTTP) Get(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                      Get makes an HTTP GET request and returns a corresponding response by taking goja.Values as arguments

                      func (*HTTP) Head

                      func (h *HTTP) Head(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                        Head makes an HTTP HEAD request and returns a corresponding response by taking goja.Values as arguments

                        func (*HTTP) Options

                        func (h *HTTP) Options(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                          Options makes an HTTP OPTIONS request and returns a corresponding response by taking goja.Values as arguments

                          func (*HTTP) Patch

                          func (h *HTTP) Patch(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                            Patch makes a patch request and returns a corresponding response by taking goja.Values as arguments

                            func (*HTTP) Post

                            func (h *HTTP) Post(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                              Post makes an HTTP POST request and returns a corresponding response by taking goja.Values as arguments

                              func (*HTTP) Put

                              func (h *HTTP) Put(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)

                                Put makes an HTTP PUT request and returns a corresponding response by taking goja.Values as arguments

                                func (*HTTP) Request

                                func (h *HTTP) Request(ctx context.Context, method string, url goja.Value, args ...goja.Value) (*Response, error)

                                  Request makes an http request of the provided `method` and returns a corresponding response by taking goja.Values as arguments

                                  func (*HTTP) URL

                                  func (http *HTTP) URL(parts []string, pieces ...string) (httpext.URL, error)

                                    URL creates new URL from the provided parts

                                    func (*HTTP) XCookieJar

                                    func (*HTTP) XCookieJar(ctx *context.Context) *HTTPCookieJar

                                    type HTTPCookieJar

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

                                      HTTPCookieJar is cookiejar.Jar wrapper to be used in js scripts

                                      func (HTTPCookieJar) CookiesForURL

                                      func (j HTTPCookieJar) CookiesForURL(url string) map[string][]string

                                        CookiesForURL return the cookies for a given url as a map of key and values

                                        func (HTTPCookieJar) Set

                                        func (j HTTPCookieJar) Set(url, name, value string, opts goja.Value) (bool, error)

                                          Set sets a cookie for a particular url with the given name value and additional opts

                                          type Response

                                          type Response struct {
                                          	*httpext.Response `js:"-"`
                                          }

                                            Response is a representation of an HTTP response to be returned to the goja VM

                                            func (res *Response) ClickLink(args ...goja.Value) (*Response, error)

                                              ClickLink parses the body as an html, looks for a link and than makes a request as if the link was clicked

                                              func (*Response) HTML

                                              func (res *Response) HTML(selector ...string) html.Selection

                                                HTML returns the body as an html.Selection

                                                func (*Response) JSON

                                                func (res *Response) JSON(selector ...string) goja.Value

                                                  JSON parses the body of a response as json and returns it to the goja VM

                                                  func (*Response) SubmitForm

                                                  func (res *Response) SubmitForm(args ...goja.Value) (*Response, error)

                                                    SubmitForm parses the body as an html looking for a from and then submitting it TODO: document the actual arguments that can be provided