Documentation ¶
Index ¶
- Constants
- Variables
- func ToURL(u interface{}) (httpext.URL, error)
- type FileData
- type HTTP
- func (h *HTTP) Batch(ctx context.Context, reqsV goja.Value) (goja.Value, error)
- func (*HTTP) CookieJar(ctx context.Context) (*HTTPCookieJar, error)
- func (h *HTTP) Del(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) File(data []byte, args ...string) FileData
- func (h *HTTP) Get(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) Head(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) Options(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) Patch(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) Post(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) Put(ctx context.Context, url goja.Value, args ...goja.Value) (*Response, error)
- func (h *HTTP) Request(ctx context.Context, method string, url goja.Value, args ...goja.Value) (*Response, error)
- func (http *HTTP) URL(parts []string, pieces ...string) (httpext.URL, error)
- func (*HTTP) XCookieJar(ctx *context.Context) *HTTPCookieJar
- type HTTPCookieJar
- type MultiSlotLimiter
- type Response
- func (res *Response) ClickLink(args ...goja.Value) (*Response, error)
- func (res *Response) GetCtx() context.Context
- func (res *Response) HTML(selector ...string) html.Selection
- func (res *Response) JSON(selector ...string) goja.Value
- func (res *Response) SubmitForm(args ...goja.Value) (*Response, error)
- type SlotLimiter
Constants ¶
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 ¶
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
Functions ¶
Types ¶
type FileData ¶ added in v0.20.0
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 (*HTTP) Batch ¶
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 ¶ added in v0.18.0
func (*HTTP) CookieJar(ctx context.Context) (*HTTPCookieJar, error)
func (*HTTP) Del ¶
Del makes an HTTP DELETE and returns a corresponding response by taking goja.Values as arguments
func (*HTTP) Get ¶
Get makes an HTTP GET request and returns a corresponding response by taking goja.Values as arguments
func (*HTTP) Head ¶
Head makes an HTTP HEAD request and returns a corresponding response by taking goja.Values as arguments
func (*HTTP) Options ¶ added in v0.19.0
Options makes an HTTP OPTIONS request and returns a corresponding response by taking goja.Values as arguments
func (*HTTP) Patch ¶
Patch makes a patch request and returns a corresponding response by taking goja.Values as arguments
func (*HTTP) Post ¶
Post makes an HTTP POST request and returns a corresponding response by taking goja.Values as arguments
func (*HTTP) Put ¶
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) XCookieJar ¶ added in v0.18.0
func (*HTTP) XCookieJar(ctx *context.Context) *HTTPCookieJar
type HTTPCookieJar ¶ added in v0.18.0
type HTTPCookieJar struct {
// contains filtered or unexported fields
}
HTTPCookieJar is cookiejar.Jar wrapper to be used in js scripts
func (HTTPCookieJar) CookiesForURL ¶ added in v0.18.0
func (j HTTPCookieJar) CookiesForURL(url string) map[string][]string
CookiesForURL return the cookies for a given url as a map of key and values
type MultiSlotLimiter ¶ added in v0.19.0
type MultiSlotLimiter struct {
// contains filtered or unexported fields
}
MultiSlotLimiter can restrict the concurrent execution of different groups of tasks to the given `slots` limit. Each group is represented with a string ID.
func NewMultiSlotLimiter ¶ added in v0.19.0
func NewMultiSlotLimiter(slots int) *MultiSlotLimiter
NewMultiSlotLimiter initializes and returns a new MultiSlotLimiter with the given slot count
func (*MultiSlotLimiter) Slot ¶ added in v0.19.0
func (l *MultiSlotLimiter) Slot(s string) SlotLimiter
Slot is used to retrieve the corresponding slot to the given string ID. If no slot with that ID exists, it creates it and saves it for future use. It is safe to call this method concurrently.
type Response ¶ added in v0.24.0
Response is a representation of an HTTP response to be returned to the goja VM TODO: refactor after https://github.com/dop251/goja/issues/84
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 SlotLimiter ¶ added in v0.18.2
type SlotLimiter chan struct{}
SlotLimiter can restrict the concurrent execution of tasks to the given `slots` limit
func NewSlotLimiter ¶ added in v0.18.2
func NewSlotLimiter(slots int) SlotLimiter
NewSlotLimiter initializes and returns a new SlotLimiter with the given slot count
func (SlotLimiter) Begin ¶ added in v0.18.2
func (sl SlotLimiter) Begin()
Begin uses up a slot to denote the start of a task exeuction. It's a noop if the number of slots is 0, and if no slots are available, it blocks and waits.
func (SlotLimiter) End ¶ added in v0.18.2
func (sl SlotLimiter) End()
End restores a slot and should be called at the end of a taks execution, preferably from a defer statement right after Begin()