2017-01-24 15:09:23 +00:00
// Package network provides the Chrome Debugging Protocol
2017-02-12 04:59:33 +00:00
// commands, types, and events for the Network domain.
2017-01-24 15:09:23 +00:00
//
// Network domain allows tracking network activities of the page. It exposes
// information about http, file, data and other requests and responses, their
// headers, bodies, timing, etc.
//
// Generated by the chromedp-gen command.
package network
2017-07-09 02:05:19 +00:00
// Code generated by chromedp-gen. DO NOT EDIT.
2017-01-24 15:09:23 +00:00
import (
"context"
"encoding/base64"
2017-01-26 07:28:34 +00:00
cdp "github.com/knq/chromedp/cdp"
2017-11-22 05:01:27 +00:00
"github.com/knq/chromedp/cdp/debugger"
2017-01-24 15:09:23 +00:00
)
// EnableParams enables network tracking, network events will now be
// delivered to the client.
type EnableParams struct {
MaxTotalBufferSize int64 ` json:"maxTotalBufferSize,omitempty" ` // Buffer size in bytes to use when preserving network payloads (XHRs, etc).
MaxResourceBufferSize int64 ` json:"maxResourceBufferSize,omitempty" ` // Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
}
// Enable enables network tracking, network events will now be delivered to
// the client.
//
// parameters:
func Enable ( ) * EnableParams {
return & EnableParams { }
}
// WithMaxTotalBufferSize buffer size in bytes to use when preserving network
// payloads (XHRs, etc).
func ( p EnableParams ) WithMaxTotalBufferSize ( maxTotalBufferSize int64 ) * EnableParams {
p . MaxTotalBufferSize = maxTotalBufferSize
return & p
}
// WithMaxResourceBufferSize per-resource buffer size in bytes to use when
// preserving network payloads (XHRs, etc).
func ( p EnableParams ) WithMaxResourceBufferSize ( maxResourceBufferSize int64 ) * EnableParams {
p . MaxResourceBufferSize = maxResourceBufferSize
return & p
}
2017-02-12 04:59:33 +00:00
// Do executes Network.enable against the provided context and
// target handler.
func ( p * EnableParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkEnable , p , nil )
2017-01-24 15:09:23 +00:00
}
// DisableParams disables network tracking, prevents network events from
// being sent to the client.
type DisableParams struct { }
// Disable disables network tracking, prevents network events from being sent
// to the client.
func Disable ( ) * DisableParams {
return & DisableParams { }
}
2017-02-12 04:59:33 +00:00
// Do executes Network.disable against the provided context and
// target handler.
func ( p * DisableParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkDisable , nil , nil )
2017-01-24 15:09:23 +00:00
}
// SetUserAgentOverrideParams allows overriding user agent with the given
// string.
type SetUserAgentOverrideParams struct {
UserAgent string ` json:"userAgent" ` // User agent to use.
}
// SetUserAgentOverride allows overriding user agent with the given string.
//
// parameters:
// userAgent - User agent to use.
func SetUserAgentOverride ( userAgent string ) * SetUserAgentOverrideParams {
return & SetUserAgentOverrideParams {
UserAgent : userAgent ,
}
}
2017-02-12 04:59:33 +00:00
// Do executes Network.setUserAgentOverride against the provided context and
// target handler.
func ( p * SetUserAgentOverrideParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkSetUserAgentOverride , p , nil )
2017-01-24 15:09:23 +00:00
}
2017-11-22 05:01:27 +00:00
// SearchInResponseBodyParams searches for given string in response content.
type SearchInResponseBodyParams struct {
RequestID RequestID ` json:"requestId" ` // Identifier of the network response to search.
Query string ` json:"query" ` // String to search for.
CaseSensitive bool ` json:"caseSensitive,omitempty" ` // If true, search is case sensitive.
IsRegex bool ` json:"isRegex,omitempty" ` // If true, treats string parameter as regex.
}
// SearchInResponseBody searches for given string in response content.
//
// parameters:
// requestID - Identifier of the network response to search.
// query - String to search for.
func SearchInResponseBody ( requestID RequestID , query string ) * SearchInResponseBodyParams {
return & SearchInResponseBodyParams {
RequestID : requestID ,
Query : query ,
}
}
// WithCaseSensitive if true, search is case sensitive.
func ( p SearchInResponseBodyParams ) WithCaseSensitive ( caseSensitive bool ) * SearchInResponseBodyParams {
p . CaseSensitive = caseSensitive
return & p
}
// WithIsRegex if true, treats string parameter as regex.
func ( p SearchInResponseBodyParams ) WithIsRegex ( isRegex bool ) * SearchInResponseBodyParams {
p . IsRegex = isRegex
return & p
}
// SearchInResponseBodyReturns return values.
type SearchInResponseBodyReturns struct {
Result [ ] * debugger . SearchMatch ` json:"result,omitempty" ` // List of search matches.
}
// Do executes Network.searchInResponseBody against the provided context and
// target handler.
//
// returns:
// result - List of search matches.
func ( p * SearchInResponseBodyParams ) Do ( ctxt context . Context , h cdp . Handler ) ( result [ ] * debugger . SearchMatch , err error ) {
// execute
var res SearchInResponseBodyReturns
err = h . Execute ( ctxt , cdp . CommandNetworkSearchInResponseBody , p , & res )
if err != nil {
return nil , err
}
return res . Result , nil
}
2017-01-24 15:09:23 +00:00
// SetExtraHTTPHeadersParams specifies whether to always send extra HTTP
// headers with the requests from this page.
type SetExtraHTTPHeadersParams struct {
2017-06-18 03:27:15 +00:00
Headers Headers ` json:"headers" ` // Map with extra HTTP headers.
2017-01-24 15:09:23 +00:00
}
// SetExtraHTTPHeaders specifies whether to always send extra HTTP headers
// with the requests from this page.
//
// parameters:
// headers - Map with extra HTTP headers.
2017-06-18 03:27:15 +00:00
func SetExtraHTTPHeaders ( headers Headers ) * SetExtraHTTPHeadersParams {
2017-01-24 15:09:23 +00:00
return & SetExtraHTTPHeadersParams {
Headers : headers ,
}
}
2017-02-12 04:59:33 +00:00
// Do executes Network.setExtraHTTPHeaders against the provided context and
// target handler.
func ( p * SetExtraHTTPHeadersParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkSetExtraHTTPHeaders , p , nil )
2017-01-24 15:09:23 +00:00
}
// GetResponseBodyParams returns content served for the given request.
type GetResponseBodyParams struct {
RequestID RequestID ` json:"requestId" ` // Identifier of the network request to get content for.
}
// GetResponseBody returns content served for the given request.
//
// parameters:
2017-01-26 07:28:34 +00:00
// requestID - Identifier of the network request to get content for.
func GetResponseBody ( requestID RequestID ) * GetResponseBodyParams {
2017-01-24 15:09:23 +00:00
return & GetResponseBodyParams {
2017-01-26 07:28:34 +00:00
RequestID : requestID ,
2017-01-24 15:09:23 +00:00
}
}
// GetResponseBodyReturns return values.
type GetResponseBodyReturns struct {
Body string ` json:"body,omitempty" ` // Response body.
Base64encoded bool ` json:"base64Encoded,omitempty" ` // True, if content was sent as base64.
}
2017-02-12 04:59:33 +00:00
// Do executes Network.getResponseBody against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// body - Response body.
2017-02-12 04:59:33 +00:00
func ( p * GetResponseBodyParams ) Do ( ctxt context . Context , h cdp . Handler ) ( body [ ] byte , err error ) {
2017-02-14 08:41:23 +00:00
// execute
var res GetResponseBodyReturns
err = h . Execute ( ctxt , cdp . CommandNetworkGetResponseBody , p , & res )
2017-01-24 15:09:23 +00:00
if err != nil {
return nil , err
}
2017-02-14 08:41:23 +00:00
// decode
var dec [ ] byte
if res . Base64encoded {
dec , err = base64 . StdEncoding . DecodeString ( res . Body )
if err != nil {
return nil , err
2017-01-24 15:09:23 +00:00
}
2017-02-14 08:41:23 +00:00
} else {
dec = [ ] byte ( res . Body )
2017-01-24 15:09:23 +00:00
}
2017-02-14 08:41:23 +00:00
return dec , nil
2017-01-24 15:09:23 +00:00
}
2017-04-04 08:44:57 +00:00
// SetBlockedURLSParams blocks URLs from loading.
2017-03-13 02:29:26 +00:00
type SetBlockedURLSParams struct {
2017-04-04 08:44:57 +00:00
Urls [ ] string ` json:"urls" ` // URL patterns to block. Wildcards ('*') are allowed.
2017-01-24 15:09:23 +00:00
}
2017-04-04 08:44:57 +00:00
// SetBlockedURLS blocks URLs from loading.
2017-01-24 15:09:23 +00:00
//
// parameters:
2017-04-04 08:44:57 +00:00
// urls - URL patterns to block. Wildcards ('*') are allowed.
2017-03-13 02:29:26 +00:00
func SetBlockedURLS ( urls [ ] string ) * SetBlockedURLSParams {
return & SetBlockedURLSParams {
Urls : urls ,
2017-01-24 15:09:23 +00:00
}
}
2017-03-13 02:29:26 +00:00
// Do executes Network.setBlockedURLs against the provided context and
2017-02-12 04:59:33 +00:00
// target handler.
2017-03-13 02:29:26 +00:00
func ( p * SetBlockedURLSParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
return h . Execute ( ctxt , cdp . CommandNetworkSetBlockedURLS , p , nil )
2017-01-24 15:09:23 +00:00
}
// ReplayXHRParams this method sends a new XMLHttpRequest which is identical
// to the original one. The following parameters should be identical: method,
// url, async, request body, extra headers, withCredentials attribute, user,
// password.
type ReplayXHRParams struct {
RequestID RequestID ` json:"requestId" ` // Identifier of XHR to replay.
}
// ReplayXHR this method sends a new XMLHttpRequest which is identical to the
// original one. The following parameters should be identical: method, url,
// async, request body, extra headers, withCredentials attribute, user,
// password.
//
// parameters:
2017-01-26 07:28:34 +00:00
// requestID - Identifier of XHR to replay.
func ReplayXHR ( requestID RequestID ) * ReplayXHRParams {
2017-01-24 15:09:23 +00:00
return & ReplayXHRParams {
2017-01-26 07:28:34 +00:00
RequestID : requestID ,
2017-01-24 15:09:23 +00:00
}
}
2017-02-12 04:59:33 +00:00
// Do executes Network.replayXHR against the provided context and
// target handler.
func ( p * ReplayXHRParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkReplayXHR , p , nil )
2017-01-24 15:09:23 +00:00
}
// ClearBrowserCacheParams clears browser cache.
type ClearBrowserCacheParams struct { }
// ClearBrowserCache clears browser cache.
func ClearBrowserCache ( ) * ClearBrowserCacheParams {
return & ClearBrowserCacheParams { }
}
2017-02-12 04:59:33 +00:00
// Do executes Network.clearBrowserCache against the provided context and
// target handler.
func ( p * ClearBrowserCacheParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkClearBrowserCache , nil , nil )
2017-01-24 15:09:23 +00:00
}
// ClearBrowserCookiesParams clears browser cookies.
type ClearBrowserCookiesParams struct { }
// ClearBrowserCookies clears browser cookies.
func ClearBrowserCookies ( ) * ClearBrowserCookiesParams {
return & ClearBrowserCookiesParams { }
}
2017-02-12 04:59:33 +00:00
// Do executes Network.clearBrowserCookies against the provided context and
// target handler.
func ( p * ClearBrowserCookiesParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkClearBrowserCookies , nil , nil )
2017-01-24 15:09:23 +00:00
}
// GetCookiesParams returns all browser cookies for the current URL.
// Depending on the backend support, will return detailed cookie information in
// the cookies field.
2017-01-24 15:21:23 +00:00
type GetCookiesParams struct {
Urls [ ] string ` json:"urls,omitempty" ` // The list of URLs for which applicable cookies will be fetched
}
2017-01-24 15:09:23 +00:00
// GetCookies returns all browser cookies for the current URL. Depending on
// the backend support, will return detailed cookie information in the cookies
// field.
2017-01-24 15:21:23 +00:00
//
// parameters:
2017-01-24 15:09:23 +00:00
func GetCookies ( ) * GetCookiesParams {
return & GetCookiesParams { }
}
2017-01-24 15:21:23 +00:00
// WithUrls the list of URLs for which applicable cookies will be fetched.
func ( p GetCookiesParams ) WithUrls ( urls [ ] string ) * GetCookiesParams {
p . Urls = urls
return & p
}
2017-01-24 15:09:23 +00:00
// GetCookiesReturns return values.
type GetCookiesReturns struct {
Cookies [ ] * Cookie ` json:"cookies,omitempty" ` // Array of cookie objects.
}
2017-02-12 04:59:33 +00:00
// Do executes Network.getCookies against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// cookies - Array of cookie objects.
2017-02-12 04:59:33 +00:00
func ( p * GetCookiesParams ) Do ( ctxt context . Context , h cdp . Handler ) ( cookies [ ] * Cookie , err error ) {
2017-02-14 08:41:23 +00:00
// execute
var res GetCookiesReturns
err = h . Execute ( ctxt , cdp . CommandNetworkGetCookies , p , & res )
2017-01-24 15:21:23 +00:00
if err != nil {
return nil , err
}
2017-02-14 08:41:23 +00:00
return res . Cookies , nil
2017-01-24 15:09:23 +00:00
}
// GetAllCookiesParams returns all browser cookies. Depending on the backend
// support, will return detailed cookie information in the cookies field.
type GetAllCookiesParams struct { }
// GetAllCookies returns all browser cookies. Depending on the backend
// support, will return detailed cookie information in the cookies field.
func GetAllCookies ( ) * GetAllCookiesParams {
return & GetAllCookiesParams { }
}
// GetAllCookiesReturns return values.
type GetAllCookiesReturns struct {
Cookies [ ] * Cookie ` json:"cookies,omitempty" ` // Array of cookie objects.
}
2017-02-12 04:59:33 +00:00
// Do executes Network.getAllCookies against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// cookies - Array of cookie objects.
2017-02-12 04:59:33 +00:00
func ( p * GetAllCookiesParams ) Do ( ctxt context . Context , h cdp . Handler ) ( cookies [ ] * Cookie , err error ) {
2017-01-24 15:09:23 +00:00
// execute
2017-02-14 08:41:23 +00:00
var res GetAllCookiesReturns
err = h . Execute ( ctxt , cdp . CommandNetworkGetAllCookies , nil , & res )
if err != nil {
return nil , err
2017-01-24 15:09:23 +00:00
}
2017-02-14 08:41:23 +00:00
return res . Cookies , nil
2017-01-24 15:09:23 +00:00
}
2017-08-20 23:56:21 +00:00
// DeleteCookiesParams deletes browser cookies with matching name and url or
// domain/path pair.
type DeleteCookiesParams struct {
Name string ` json:"name" ` // Name of the cookies to remove.
URL string ` json:"url,omitempty" ` // If specified, deletes all the cookies with the given name where domain and path match provided URL.
Domain string ` json:"domain,omitempty" ` // If specified, deletes only cookies with the exact domain.
Path string ` json:"path,omitempty" ` // If specified, deletes only cookies with the exact path.
2017-01-24 15:09:23 +00:00
}
2017-08-20 23:56:21 +00:00
// DeleteCookies deletes browser cookies with matching name and url or
// domain/path pair.
2017-01-24 15:09:23 +00:00
//
// parameters:
2017-08-20 23:56:21 +00:00
// name - Name of the cookies to remove.
func DeleteCookies ( name string ) * DeleteCookiesParams {
return & DeleteCookiesParams {
Name : name ,
2017-01-24 15:09:23 +00:00
}
}
2017-08-20 23:56:21 +00:00
// WithURL if specified, deletes all the cookies with the given name where
// domain and path match provided URL.
func ( p DeleteCookiesParams ) WithURL ( url string ) * DeleteCookiesParams {
p . URL = url
return & p
}
// WithDomain if specified, deletes only cookies with the exact domain.
func ( p DeleteCookiesParams ) WithDomain ( domain string ) * DeleteCookiesParams {
p . Domain = domain
return & p
}
// WithPath if specified, deletes only cookies with the exact path.
func ( p DeleteCookiesParams ) WithPath ( path string ) * DeleteCookiesParams {
p . Path = path
return & p
}
// Do executes Network.deleteCookies against the provided context and
2017-02-12 04:59:33 +00:00
// target handler.
2017-08-20 23:56:21 +00:00
func ( p * DeleteCookiesParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
return h . Execute ( ctxt , cdp . CommandNetworkDeleteCookies , p , nil )
2017-01-24 15:09:23 +00:00
}
// SetCookieParams sets a cookie with the given cookie data; may overwrite
// equivalent cookies if they exist.
type SetCookieParams struct {
2017-08-20 23:56:21 +00:00
Name string ` json:"name" ` // Cookie name.
Value string ` json:"value" ` // Cookie value.
URL string ` json:"url,omitempty" ` // The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie.
Domain string ` json:"domain,omitempty" ` // Cookie domain.
Path string ` json:"path,omitempty" ` // Cookie path.
Secure bool ` json:"secure,omitempty" ` // True if cookie is secure.
HTTPOnly bool ` json:"httpOnly,omitempty" ` // True if cookie is http-only.
SameSite CookieSameSite ` json:"sameSite,omitempty" ` // Cookie SameSite type.
Expires * cdp . TimeSinceEpoch ` json:"expires,omitempty" ` // Cookie expiration date, session cookie if not set
2017-01-24 15:09:23 +00:00
}
// SetCookie sets a cookie with the given cookie data; may overwrite
// equivalent cookies if they exist.
//
// parameters:
2017-08-20 23:56:21 +00:00
// name - Cookie name.
// value - Cookie value.
func SetCookie ( name string , value string ) * SetCookieParams {
2017-01-24 15:09:23 +00:00
return & SetCookieParams {
Name : name ,
Value : value ,
}
}
2017-08-20 23:56:21 +00:00
// WithURL the request-URI to associate with the setting of the cookie. This
// value can affect the default domain and path values of the created cookie.
func ( p SetCookieParams ) WithURL ( url string ) * SetCookieParams {
p . URL = url
return & p
}
// WithDomain cookie domain.
2017-01-24 15:09:23 +00:00
func ( p SetCookieParams ) WithDomain ( domain string ) * SetCookieParams {
p . Domain = domain
return & p
}
2017-08-20 23:56:21 +00:00
// WithPath cookie path.
2017-01-24 15:09:23 +00:00
func ( p SetCookieParams ) WithPath ( path string ) * SetCookieParams {
p . Path = path
return & p
}
2017-08-20 23:56:21 +00:00
// WithSecure true if cookie is secure.
2017-01-24 15:09:23 +00:00
func ( p SetCookieParams ) WithSecure ( secure bool ) * SetCookieParams {
p . Secure = secure
return & p
}
2017-08-20 23:56:21 +00:00
// WithHTTPOnly true if cookie is http-only.
2017-01-24 15:09:23 +00:00
func ( p SetCookieParams ) WithHTTPOnly ( httpOnly bool ) * SetCookieParams {
p . HTTPOnly = httpOnly
return & p
}
2017-08-20 23:56:21 +00:00
// WithSameSite cookie SameSite type.
2017-01-24 15:09:23 +00:00
func ( p SetCookieParams ) WithSameSite ( sameSite CookieSameSite ) * SetCookieParams {
p . SameSite = sameSite
return & p
}
2017-08-20 23:56:21 +00:00
// WithExpires cookie expiration date, session cookie if not set.
func ( p SetCookieParams ) WithExpires ( expires * cdp . TimeSinceEpoch ) * SetCookieParams {
p . Expires = expires
2017-01-24 15:09:23 +00:00
return & p
}
// SetCookieReturns return values.
type SetCookieReturns struct {
Success bool ` json:"success,omitempty" ` // True if successfully set cookie.
}
2017-02-12 04:59:33 +00:00
// Do executes Network.setCookie against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// success - True if successfully set cookie.
2017-02-12 04:59:33 +00:00
func ( p * SetCookieParams ) Do ( ctxt context . Context , h cdp . Handler ) ( success bool , err error ) {
2017-02-14 08:41:23 +00:00
// execute
var res SetCookieReturns
err = h . Execute ( ctxt , cdp . CommandNetworkSetCookie , p , & res )
2017-01-24 15:09:23 +00:00
if err != nil {
return false , err
}
2017-02-14 08:41:23 +00:00
return res . Success , nil
2017-01-24 15:09:23 +00:00
}
2017-08-20 23:56:21 +00:00
// SetCookiesParams sets given cookies.
type SetCookiesParams struct {
Cookies [ ] * CookieParam ` json:"cookies" ` // Cookies to be set.
}
// SetCookies sets given cookies.
//
// parameters:
// cookies - Cookies to be set.
func SetCookies ( cookies [ ] * CookieParam ) * SetCookiesParams {
return & SetCookiesParams {
Cookies : cookies ,
}
}
// Do executes Network.setCookies against the provided context and
// target handler.
func ( p * SetCookiesParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
return h . Execute ( ctxt , cdp . CommandNetworkSetCookies , p , nil )
}
2017-01-24 15:09:23 +00:00
// EmulateNetworkConditionsParams activates emulation of network conditions.
type EmulateNetworkConditionsParams struct {
Offline bool ` json:"offline" ` // True to emulate internet disconnection.
2017-09-15 23:52:13 +00:00
Latency float64 ` json:"latency" ` // Minimum latency from request sent to response headers received (ms).
DownloadThroughput float64 ` json:"downloadThroughput" ` // Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
UploadThroughput float64 ` json:"uploadThroughput" ` // Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.
2017-01-24 15:09:23 +00:00
ConnectionType ConnectionType ` json:"connectionType,omitempty" ` // Connection type if known.
}
// EmulateNetworkConditions activates emulation of network conditions.
//
// parameters:
// offline - True to emulate internet disconnection.
2017-09-15 23:52:13 +00:00
// latency - Minimum latency from request sent to response headers received (ms).
// downloadThroughput - Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
// uploadThroughput - Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.
2017-01-24 15:09:23 +00:00
func EmulateNetworkConditions ( offline bool , latency float64 , downloadThroughput float64 , uploadThroughput float64 ) * EmulateNetworkConditionsParams {
return & EmulateNetworkConditionsParams {
Offline : offline ,
Latency : latency ,
DownloadThroughput : downloadThroughput ,
UploadThroughput : uploadThroughput ,
}
}
// WithConnectionType connection type if known.
func ( p EmulateNetworkConditionsParams ) WithConnectionType ( connectionType ConnectionType ) * EmulateNetworkConditionsParams {
p . ConnectionType = connectionType
return & p
}
2017-02-12 04:59:33 +00:00
// Do executes Network.emulateNetworkConditions against the provided context and
// target handler.
func ( p * EmulateNetworkConditionsParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkEmulateNetworkConditions , p , nil )
2017-01-24 15:09:23 +00:00
}
// SetCacheDisabledParams toggles ignoring cache for each request. If true,
// cache will not be used.
type SetCacheDisabledParams struct {
CacheDisabled bool ` json:"cacheDisabled" ` // Cache disabled state.
}
// SetCacheDisabled toggles ignoring cache for each request. If true, cache
// will not be used.
//
// parameters:
// cacheDisabled - Cache disabled state.
func SetCacheDisabled ( cacheDisabled bool ) * SetCacheDisabledParams {
return & SetCacheDisabledParams {
CacheDisabled : cacheDisabled ,
}
}
2017-02-12 04:59:33 +00:00
// Do executes Network.setCacheDisabled against the provided context and
// target handler.
func ( p * SetCacheDisabledParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkSetCacheDisabled , p , nil )
2017-01-24 15:09:23 +00:00
}
// SetBypassServiceWorkerParams toggles ignoring of service worker for each
// request.
type SetBypassServiceWorkerParams struct {
Bypass bool ` json:"bypass" ` // Bypass service worker and load from network.
}
// SetBypassServiceWorker toggles ignoring of service worker for each
// request.
//
// parameters:
// bypass - Bypass service worker and load from network.
func SetBypassServiceWorker ( bypass bool ) * SetBypassServiceWorkerParams {
return & SetBypassServiceWorkerParams {
Bypass : bypass ,
}
}
2017-02-12 04:59:33 +00:00
// Do executes Network.setBypassServiceWorker against the provided context and
// target handler.
func ( p * SetBypassServiceWorkerParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkSetBypassServiceWorker , p , nil )
2017-01-24 15:09:23 +00:00
}
// SetDataSizeLimitsForTestParams for testing.
type SetDataSizeLimitsForTestParams struct {
MaxTotalSize int64 ` json:"maxTotalSize" ` // Maximum total buffer size.
MaxResourceSize int64 ` json:"maxResourceSize" ` // Maximum per-resource size.
}
// SetDataSizeLimitsForTest for testing.
//
// parameters:
// maxTotalSize - Maximum total buffer size.
// maxResourceSize - Maximum per-resource size.
func SetDataSizeLimitsForTest ( maxTotalSize int64 , maxResourceSize int64 ) * SetDataSizeLimitsForTestParams {
return & SetDataSizeLimitsForTestParams {
MaxTotalSize : maxTotalSize ,
MaxResourceSize : maxResourceSize ,
}
}
2017-02-12 04:59:33 +00:00
// Do executes Network.setDataSizeLimitsForTest against the provided context and
// target handler.
func ( p * SetDataSizeLimitsForTestParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
2017-02-14 08:41:23 +00:00
return h . Execute ( ctxt , cdp . CommandNetworkSetDataSizeLimitsForTest , p , nil )
2017-01-24 15:09:23 +00:00
}
// GetCertificateParams returns the DER-encoded certificate.
type GetCertificateParams struct {
Origin string ` json:"origin" ` // Origin to get certificate for.
}
// GetCertificate returns the DER-encoded certificate.
//
// parameters:
// origin - Origin to get certificate for.
func GetCertificate ( origin string ) * GetCertificateParams {
return & GetCertificateParams {
Origin : origin ,
}
}
// GetCertificateReturns return values.
type GetCertificateReturns struct {
TableNames [ ] string ` json:"tableNames,omitempty" `
}
2017-02-12 04:59:33 +00:00
// Do executes Network.getCertificate against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// tableNames
2017-02-12 04:59:33 +00:00
func ( p * GetCertificateParams ) Do ( ctxt context . Context , h cdp . Handler ) ( tableNames [ ] string , err error ) {
2017-02-14 08:41:23 +00:00
// execute
var res GetCertificateReturns
err = h . Execute ( ctxt , cdp . CommandNetworkGetCertificate , p , & res )
2017-01-24 15:09:23 +00:00
if err != nil {
return nil , err
}
2017-02-14 08:41:23 +00:00
return res . TableNames , nil
2017-01-24 15:09:23 +00:00
}
2017-06-06 10:57:18 +00:00
2017-10-24 02:06:01 +00:00
// SetRequestInterceptionParams sets the requests to intercept that match a
// the provided patterns and optionally resource types.
type SetRequestInterceptionParams struct {
Patterns [ ] * RequestPattern ` json:"patterns" ` // Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
2017-06-06 10:57:18 +00:00
}
2017-10-24 02:06:01 +00:00
// SetRequestInterception sets the requests to intercept that match a the
// provided patterns and optionally resource types.
2017-06-06 10:57:18 +00:00
//
// parameters:
2017-10-24 02:06:01 +00:00
// patterns - Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
func SetRequestInterception ( patterns [ ] * RequestPattern ) * SetRequestInterceptionParams {
return & SetRequestInterceptionParams {
Patterns : patterns ,
2017-06-06 10:57:18 +00:00
}
}
2017-10-24 02:06:01 +00:00
// Do executes Network.setRequestInterception against the provided context and
2017-06-06 10:57:18 +00:00
// target handler.
2017-10-24 02:06:01 +00:00
func ( p * SetRequestInterceptionParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
return h . Execute ( ctxt , cdp . CommandNetworkSetRequestInterception , p , nil )
2017-06-06 10:57:18 +00:00
}
// ContinueInterceptedRequestParams response to Network.requestIntercepted
// which either modifies the request to continue with any modifications, or
// blocks it, or completes it with the provided response bytes. If a network
// fetch occurs as a result which encounters a redirect an additional
// Network.requestIntercepted event will be sent with the same InterceptionId.
type ContinueInterceptedRequestParams struct {
2017-06-18 00:55:45 +00:00
InterceptionID InterceptionID ` json:"interceptionId" `
2017-08-03 05:37:27 +00:00
ErrorReason ErrorReason ` json:"errorReason,omitempty" ` // If set this causes the request to fail with the given reason. Passing Aborted for requests marked with isNavigationRequest also cancels the navigation. Must not be set in response to an authChallenge.
2017-06-18 00:55:45 +00:00
RawResponse string ` json:"rawResponse,omitempty" ` // If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc... Must not be set in response to an authChallenge.
URL string ` json:"url,omitempty" ` // If set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallenge.
Method string ` json:"method,omitempty" ` // If set this allows the request method to be overridden. Must not be set in response to an authChallenge.
PostData string ` json:"postData,omitempty" ` // If set this allows postData to be set. Must not be set in response to an authChallenge.
2017-06-18 03:27:15 +00:00
Headers Headers ` json:"headers,omitempty" ` // If set this allows the request headers to be changed. Must not be set in response to an authChallenge.
2017-06-18 00:55:45 +00:00
AuthChallengeResponse * AuthChallengeResponse ` json:"authChallengeResponse,omitempty" ` // Response to a requestIntercepted with an authChallenge. Must not be set otherwise.
2017-06-06 10:57:18 +00:00
}
// ContinueInterceptedRequest response to Network.requestIntercepted which
// either modifies the request to continue with any modifications, or blocks it,
// or completes it with the provided response bytes. If a network fetch occurs
// as a result which encounters a redirect an additional
// Network.requestIntercepted event will be sent with the same InterceptionId.
//
// parameters:
// interceptionID
func ContinueInterceptedRequest ( interceptionID InterceptionID ) * ContinueInterceptedRequestParams {
return & ContinueInterceptedRequestParams {
InterceptionID : interceptionID ,
}
}
// WithErrorReason if set this causes the request to fail with the given
2017-08-03 05:37:27 +00:00
// reason. Passing Aborted for requests marked with isNavigationRequest also
// cancels the navigation. Must not be set in response to an authChallenge.
2017-06-06 10:57:18 +00:00
func ( p ContinueInterceptedRequestParams ) WithErrorReason ( errorReason ErrorReason ) * ContinueInterceptedRequestParams {
p . ErrorReason = errorReason
return & p
}
// WithRawResponse if set the requests completes using with the provided
// base64 encoded raw response, including HTTP status line and headers etc...
2017-06-18 00:55:45 +00:00
// Must not be set in response to an authChallenge.
2017-06-06 10:57:18 +00:00
func ( p ContinueInterceptedRequestParams ) WithRawResponse ( rawResponse string ) * ContinueInterceptedRequestParams {
p . RawResponse = rawResponse
return & p
}
// WithURL if set the request url will be modified in a way that's not
2017-06-18 00:55:45 +00:00
// observable by page. Must not be set in response to an authChallenge.
2017-06-06 10:57:18 +00:00
func ( p ContinueInterceptedRequestParams ) WithURL ( url string ) * ContinueInterceptedRequestParams {
p . URL = url
return & p
}
2017-06-18 00:55:45 +00:00
// WithMethod if set this allows the request method to be overridden. Must
// not be set in response to an authChallenge.
2017-06-06 10:57:18 +00:00
func ( p ContinueInterceptedRequestParams ) WithMethod ( method string ) * ContinueInterceptedRequestParams {
p . Method = method
return & p
}
2017-06-18 00:55:45 +00:00
// WithPostData if set this allows postData to be set. Must not be set in
// response to an authChallenge.
2017-06-06 10:57:18 +00:00
func ( p ContinueInterceptedRequestParams ) WithPostData ( postData string ) * ContinueInterceptedRequestParams {
p . PostData = postData
return & p
}
2017-06-18 00:55:45 +00:00
// WithHeaders if set this allows the request headers to be changed. Must not
// be set in response to an authChallenge.
2017-06-18 03:27:15 +00:00
func ( p ContinueInterceptedRequestParams ) WithHeaders ( headers Headers ) * ContinueInterceptedRequestParams {
2017-06-06 10:57:18 +00:00
p . Headers = headers
return & p
}
2017-06-18 00:55:45 +00:00
// WithAuthChallengeResponse response to a requestIntercepted with an
// authChallenge. Must not be set otherwise.
func ( p ContinueInterceptedRequestParams ) WithAuthChallengeResponse ( authChallengeResponse * AuthChallengeResponse ) * ContinueInterceptedRequestParams {
p . AuthChallengeResponse = authChallengeResponse
return & p
}
2017-06-06 10:57:18 +00:00
// Do executes Network.continueInterceptedRequest against the provided context and
// target handler.
func ( p * ContinueInterceptedRequestParams ) Do ( ctxt context . Context , h cdp . Handler ) ( err error ) {
return h . Execute ( ctxt , cdp . CommandNetworkContinueInterceptedRequest , p , nil )
}
2017-11-22 05:01:27 +00:00
// GetResponseBodyForInterceptionParams returns content served for the given
// currently intercepted request.
type GetResponseBodyForInterceptionParams struct {
InterceptionID InterceptionID ` json:"interceptionId" ` // Identifier for the intercepted request to get body for.
}
// GetResponseBodyForInterception returns content served for the given
// currently intercepted request.
//
// parameters:
// interceptionID - Identifier for the intercepted request to get body for.
func GetResponseBodyForInterception ( interceptionID InterceptionID ) * GetResponseBodyForInterceptionParams {
return & GetResponseBodyForInterceptionParams {
InterceptionID : interceptionID ,
}
}
// GetResponseBodyForInterceptionReturns return values.
type GetResponseBodyForInterceptionReturns struct {
Body string ` json:"body,omitempty" ` // Response body.
Base64encoded bool ` json:"base64Encoded,omitempty" ` // True, if content was sent as base64.
}
// Do executes Network.getResponseBodyForInterception against the provided context and
// target handler.
//
// returns:
// body - Response body.
func ( p * GetResponseBodyForInterceptionParams ) Do ( ctxt context . Context , h cdp . Handler ) ( body [ ] byte , err error ) {
// execute
var res GetResponseBodyForInterceptionReturns
err = h . Execute ( ctxt , cdp . CommandNetworkGetResponseBodyForInterception , p , & res )
if err != nil {
return nil , err
}
// decode
var dec [ ] byte
if res . Base64encoded {
dec , err = base64 . StdEncoding . DecodeString ( res . Body )
if err != nil {
return nil , err
}
} else {
dec = [ ] byte ( res . Body )
}
return dec , nil
}