Updating to latest protocol.json

This commit is contained in:
Kenneth Shaw 2017-06-06 17:57:18 +07:00
parent d2a7882b93
commit 91303cba34
11 changed files with 795 additions and 136 deletions

View File

@ -156,6 +156,7 @@ const (
EventNetworkWebSocketFrameError MethodType = "Network.webSocketFrameError" EventNetworkWebSocketFrameError MethodType = "Network.webSocketFrameError"
EventNetworkWebSocketFrameSent MethodType = "Network.webSocketFrameSent" EventNetworkWebSocketFrameSent MethodType = "Network.webSocketFrameSent"
EventNetworkEventSourceMessageReceived MethodType = "Network.eventSourceMessageReceived" EventNetworkEventSourceMessageReceived MethodType = "Network.eventSourceMessageReceived"
EventNetworkRequestIntercepted MethodType = "Network.requestIntercepted"
CommandNetworkEnable MethodType = "Network.enable" CommandNetworkEnable MethodType = "Network.enable"
CommandNetworkDisable MethodType = "Network.disable" CommandNetworkDisable MethodType = "Network.disable"
CommandNetworkSetUserAgentOverride MethodType = "Network.setUserAgentOverride" CommandNetworkSetUserAgentOverride MethodType = "Network.setUserAgentOverride"
@ -177,6 +178,8 @@ const (
CommandNetworkSetBypassServiceWorker MethodType = "Network.setBypassServiceWorker" CommandNetworkSetBypassServiceWorker MethodType = "Network.setBypassServiceWorker"
CommandNetworkSetDataSizeLimitsForTest MethodType = "Network.setDataSizeLimitsForTest" CommandNetworkSetDataSizeLimitsForTest MethodType = "Network.setDataSizeLimitsForTest"
CommandNetworkGetCertificate MethodType = "Network.getCertificate" CommandNetworkGetCertificate MethodType = "Network.getCertificate"
CommandNetworkEnableRequestInterception MethodType = "Network.enableRequestInterception"
CommandNetworkContinueInterceptedRequest MethodType = "Network.continueInterceptedRequest"
EventDatabaseAddDatabase MethodType = "Database.addDatabase" EventDatabaseAddDatabase MethodType = "Database.addDatabase"
CommandDatabaseEnable MethodType = "Database.enable" CommandDatabaseEnable MethodType = "Database.enable"
CommandDatabaseDisable MethodType = "Database.disable" CommandDatabaseDisable MethodType = "Database.disable"
@ -694,6 +697,8 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = EventNetworkWebSocketFrameSent *t = EventNetworkWebSocketFrameSent
case EventNetworkEventSourceMessageReceived: case EventNetworkEventSourceMessageReceived:
*t = EventNetworkEventSourceMessageReceived *t = EventNetworkEventSourceMessageReceived
case EventNetworkRequestIntercepted:
*t = EventNetworkRequestIntercepted
case CommandNetworkEnable: case CommandNetworkEnable:
*t = CommandNetworkEnable *t = CommandNetworkEnable
case CommandNetworkDisable: case CommandNetworkDisable:
@ -736,6 +741,10 @@ func (t *MethodType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = CommandNetworkSetDataSizeLimitsForTest *t = CommandNetworkSetDataSizeLimitsForTest
case CommandNetworkGetCertificate: case CommandNetworkGetCertificate:
*t = CommandNetworkGetCertificate *t = CommandNetworkGetCertificate
case CommandNetworkEnableRequestInterception:
*t = CommandNetworkEnableRequestInterception
case CommandNetworkContinueInterceptedRequest:
*t = CommandNetworkContinueInterceptedRequest
case EventDatabaseAddDatabase: case EventDatabaseAddDatabase:
*t = EventDatabaseAddDatabase *t = EventDatabaseAddDatabase
case CommandDatabaseEnable: case CommandDatabaseEnable:

View File

@ -387,6 +387,12 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.CommandNetworkGetCertificate: case cdp.CommandNetworkGetCertificate:
v = new(network.GetCertificateReturns) v = new(network.GetCertificateReturns)
case cdp.CommandNetworkEnableRequestInterception:
return emptyVal, nil
case cdp.CommandNetworkContinueInterceptedRequest:
return emptyVal, nil
case cdp.EventNetworkResourceChangedPriority: case cdp.EventNetworkResourceChangedPriority:
v = new(network.EventResourceChangedPriority) v = new(network.EventResourceChangedPriority)
@ -432,6 +438,9 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
case cdp.EventNetworkEventSourceMessageReceived: case cdp.EventNetworkEventSourceMessageReceived:
v = new(network.EventEventSourceMessageReceived) v = new(network.EventEventSourceMessageReceived)
case cdp.EventNetworkRequestIntercepted:
v = new(network.EventRequestIntercepted)
case cdp.CommandDatabaseEnable: case cdp.CommandDatabaseEnable:
return emptyVal, nil return emptyVal, nil

File diff suppressed because it is too large Load Diff

View File

@ -130,6 +130,16 @@ type EventEventSourceMessageReceived struct {
Data string `json:"data,omitempty"` // Message content. Data string `json:"data,omitempty"` // Message content.
} }
// EventRequestIntercepted details of an intercepted HTTP request, which must
// be either allowed, blocked, modified or mocked.
type EventRequestIntercepted struct {
InterceptionID InterceptionID `json:"InterceptionId,omitempty"` // Each request the page makes will have a unique id, however if any redirects are encountered while processing that fetch, they will be reported with the same id as the original fetch.
Request *Request `json:"request,omitempty"`
RedirectHeaders *Headers `json:"redirectHeaders,omitempty"` // HTTP response headers, only sent if a redirect was intercepted.
RedirectStatusCode int64 `json:"redirectStatusCode,omitempty"` // HTTP response code, only sent if a redirect was intercepted.
RedirectURL string `json:"redirectUrl,omitempty"` // Redirect location, only sent if a redirect was intercepted.
}
// EventTypes all event types in the domain. // EventTypes all event types in the domain.
var EventTypes = []cdp.MethodType{ var EventTypes = []cdp.MethodType{
cdp.EventNetworkResourceChangedPriority, cdp.EventNetworkResourceChangedPriority,
@ -147,4 +157,5 @@ var EventTypes = []cdp.MethodType{
cdp.EventNetworkWebSocketFrameError, cdp.EventNetworkWebSocketFrameError,
cdp.EventNetworkWebSocketFrameSent, cdp.EventNetworkWebSocketFrameSent,
cdp.EventNetworkEventSourceMessageReceived, cdp.EventNetworkEventSourceMessageReceived,
cdp.EventNetworkRequestIntercepted,
} }

View File

@ -655,3 +655,98 @@ func (p *GetCertificateParams) Do(ctxt context.Context, h cdp.Handler) (tableNam
return res.TableNames, nil return res.TableNames, nil
} }
// EnableRequestInterceptionParams [no description].
type EnableRequestInterceptionParams struct {
Enabled bool `json:"enabled"` // Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent.
}
// EnableRequestInterception [no description].
//
// parameters:
// enabled - Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent.
func EnableRequestInterception(enabled bool) *EnableRequestInterceptionParams {
return &EnableRequestInterceptionParams{
Enabled: enabled,
}
}
// Do executes Network.enableRequestInterception against the provided context and
// target handler.
func (p *EnableRequestInterceptionParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandNetworkEnableRequestInterception, p, nil)
}
// 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 {
InterceptionID InterceptionID `json:"interceptionId"`
ErrorReason ErrorReason `json:"errorReason,omitempty"` // If set this causes the request to fail with the given reason.
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...
URL string `json:"url,omitempty"` // If set the request url will be modified in a way that's not observable by page.
Method string `json:"method,omitempty"` // If set this allows the request method to be overridden.
PostData string `json:"postData,omitempty"` // If set this allows postData to be set.
Headers *Headers `json:"headers,omitempty"` // If set this allows the request headers to be changed.
}
// 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
// reason.
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...
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
// observable by page.
func (p ContinueInterceptedRequestParams) WithURL(url string) *ContinueInterceptedRequestParams {
p.URL = url
return &p
}
// WithMethod if set this allows the request method to be overridden.
func (p ContinueInterceptedRequestParams) WithMethod(method string) *ContinueInterceptedRequestParams {
p.Method = method
return &p
}
// WithPostData if set this allows postData to be set.
func (p ContinueInterceptedRequestParams) WithPostData(postData string) *ContinueInterceptedRequestParams {
p.PostData = postData
return &p
}
// WithHeaders if set this allows the request headers to be changed.
func (p ContinueInterceptedRequestParams) WithHeaders(headers *Headers) *ContinueInterceptedRequestParams {
p.Headers = headers
return &p
}
// 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)
}

View File

@ -22,6 +22,86 @@ func (t RequestID) String() string {
return string(t) return string(t)
} }
// InterceptionID unique intercepted request identifier.
type InterceptionID string
// String returns the InterceptionID as string value.
func (t InterceptionID) String() string {
return string(t)
}
// ErrorReason network level fetch failure reason.
type ErrorReason string
// String returns the ErrorReason as string value.
func (t ErrorReason) String() string {
return string(t)
}
// ErrorReason values.
const (
ErrorReasonFailed ErrorReason = "Failed"
ErrorReasonAborted ErrorReason = "Aborted"
ErrorReasonTimedOut ErrorReason = "TimedOut"
ErrorReasonAccessDenied ErrorReason = "AccessDenied"
ErrorReasonConnectionClosed ErrorReason = "ConnectionClosed"
ErrorReasonConnectionReset ErrorReason = "ConnectionReset"
ErrorReasonConnectionRefused ErrorReason = "ConnectionRefused"
ErrorReasonConnectionAborted ErrorReason = "ConnectionAborted"
ErrorReasonConnectionFailed ErrorReason = "ConnectionFailed"
ErrorReasonNameNotResolved ErrorReason = "NameNotResolved"
ErrorReasonInternetDisconnected ErrorReason = "InternetDisconnected"
ErrorReasonAddressUnreachable ErrorReason = "AddressUnreachable"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ErrorReason) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ErrorReason) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ErrorReason) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ErrorReason(in.String()) {
case ErrorReasonFailed:
*t = ErrorReasonFailed
case ErrorReasonAborted:
*t = ErrorReasonAborted
case ErrorReasonTimedOut:
*t = ErrorReasonTimedOut
case ErrorReasonAccessDenied:
*t = ErrorReasonAccessDenied
case ErrorReasonConnectionClosed:
*t = ErrorReasonConnectionClosed
case ErrorReasonConnectionReset:
*t = ErrorReasonConnectionReset
case ErrorReasonConnectionRefused:
*t = ErrorReasonConnectionRefused
case ErrorReasonConnectionAborted:
*t = ErrorReasonConnectionAborted
case ErrorReasonConnectionFailed:
*t = ErrorReasonConnectionFailed
case ErrorReasonNameNotResolved:
*t = ErrorReasonNameNotResolved
case ErrorReasonInternetDisconnected:
*t = ErrorReasonInternetDisconnected
case ErrorReasonAddressUnreachable:
*t = ErrorReasonAddressUnreachable
default:
in.AddError(errors.New("unknown ErrorReason value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ErrorReason) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// Headers request / response headers as keys / values of JSON object. // Headers request / response headers as keys / values of JSON object.
type Headers struct{} type Headers struct{}

View File

@ -2343,6 +2343,30 @@
"type": "string", "type": "string",
"description": "Unique request identifier." "description": "Unique request identifier."
}, },
{
"id": "InterceptionId",
"type": "string",
"description": "Unique intercepted request identifier."
},
{
"id": "ErrorReason",
"type": "string",
"enum": [
"Failed",
"Aborted",
"TimedOut",
"AccessDenied",
"ConnectionClosed",
"ConnectionReset",
"ConnectionRefused",
"ConnectionAborted",
"ConnectionFailed",
"NameNotResolved",
"InternetDisconnected",
"AddressUnreachable"
],
"description": "Network level fetch failure reason."
},
{ {
"id": "Timestamp", "id": "Timestamp",
"type": "number", "type": "number",
@ -3350,6 +3374,64 @@
} }
], ],
"experimental": true "experimental": true
},
{
"name": "enableRequestInterception",
"parameters": [
{
"name": "enabled",
"type": "boolean",
"description": "Whether or not HTTP requests should be intercepted and Network.requestIntercepted events sent."
}
],
"experimental": true
},
{
"name": "continueInterceptedRequest",
"description": "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": [
{
"name": "interceptionId",
"$ref": "InterceptionId"
},
{
"name": "errorReason",
"$ref": "ErrorReason",
"optional": true,
"description": "If set this causes the request to fail with the given reason."
},
{
"name": "rawResponse",
"type": "string",
"optional": true,
"description": "If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc..."
},
{
"name": "url",
"type": "string",
"optional": true,
"description": "If set the request url will be modified in a way that's not observable by page."
},
{
"name": "method",
"type": "string",
"optional": true,
"description": "If set this allows the request method to be overridden."
},
{
"name": "postData",
"type": "string",
"optional": true,
"description": "If set this allows postData to be set."
},
{
"name": "headers",
"$ref": "Headers",
"optional": true,
"description": "If set this allows the request headers to be changed."
}
],
"experimental": true
} }
], ],
"events": [ "events": [
@ -3757,6 +3839,40 @@
} }
], ],
"experimental": true "experimental": true
},
{
"name": "requestIntercepted",
"description": "Details of an intercepted HTTP request, which must be either allowed, blocked, modified or mocked.",
"parameters": [
{
"name": "InterceptionId",
"$ref": "InterceptionId",
"description": "Each request the page makes will have a unique id, however if any redirects are encountered while processing that fetch, they will be reported with the same id as the original fetch."
},
{
"name": "request",
"$ref": "Request"
},
{
"name": "redirectHeaders",
"$ref": "Headers",
"optional": true,
"description": "HTTP response headers, only sent if a redirect was intercepted."
},
{
"name": "redirectStatusCode",
"type": "integer",
"optional": true,
"description": "HTTP response code, only sent if a redirect was intercepted."
},
{
"name": "redirectUrl",
"optional": true,
"type": "string",
"description": "Redirect location, only sent if a redirect was intercepted."
}
],
"experimental": true
} }
] ]
}, },

View File

@ -4,13 +4,6 @@
//line templates/domain.qtpl:1 //line templates/domain.qtpl:1
package templates package templates
//line templates/domain.qtpl:1
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/domain.qtpl:1 //line templates/domain.qtpl:1
import ( import (
"github.com/knq/chromedp/cmd/chromedp-gen/internal" "github.com/knq/chromedp/cmd/chromedp-gen/internal"
@ -18,6 +11,13 @@ import (
// DomainTemplate is the template for a single domain. // DomainTemplate is the template for a single domain.
//line templates/domain.qtpl:6
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/domain.qtpl:6 //line templates/domain.qtpl:6
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy

View File

@ -4,13 +4,6 @@
//line templates/extra.qtpl:1 //line templates/extra.qtpl:1
package templates package templates
//line templates/extra.qtpl:1
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/extra.qtpl:1 //line templates/extra.qtpl:1
import ( import (
"github.com/knq/chromedp/cmd/chromedp-gen/internal" "github.com/knq/chromedp/cmd/chromedp-gen/internal"
@ -19,6 +12,13 @@ import (
// ExtraTimestampTemplate is a special template for the Timestamp type that // ExtraTimestampTemplate is a special template for the Timestamp type that
// defines its JSON unmarshaling. // defines its JSON unmarshaling.
//line templates/extra.qtpl:7
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/extra.qtpl:7 //line templates/extra.qtpl:7
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy

View File

@ -4,13 +4,6 @@
//line templates/file.qtpl:1 //line templates/file.qtpl:1
package templates package templates
//line templates/file.qtpl:1
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/file.qtpl:1 //line templates/file.qtpl:1
import ( import (
"sort" "sort"
@ -20,6 +13,13 @@ import (
// FileHeader is the file header template. // FileHeader is the file header template.
//line templates/file.qtpl:8
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/file.qtpl:8 //line templates/file.qtpl:8
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy

View File

@ -4,13 +4,6 @@
//line templates/type.qtpl:1 //line templates/type.qtpl:1
package templates package templates
//line templates/type.qtpl:1
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/type.qtpl:1 //line templates/type.qtpl:1
import ( import (
"strconv" "strconv"
@ -21,6 +14,13 @@ import (
// TypeTemplate is a template for a Typable type. // TypeTemplate is a template for a Typable type.
//line templates/type.qtpl:9
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line templates/type.qtpl:9 //line templates/type.qtpl:9
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy