Class Network


  • public class Network
    extends java.lang.Object
    Class created by Automatic Code-Generator.
    This class was built using the Chrome Remote Dev-Tools A.P.I., which is specified by two JSON-RPC Files. These files were obtained from the Chrome Dev Tools Protocol Git Hub Page, which has a "Tip of Tree" (the latest) API-Specification Page Here: JSON-RPC Protocol Specification.

    JSON-Viewable Google-API:
    These files may be viewed here: browser_protocol.json and js_protocol.json.
    These files were converted into this Java-Browser (CDT) Library; they are a Java-Alternative to the Node.js implementation.

    HTML-Viewable API:
    In addition to this Class-Library, these files were also converted to a simple HTML Page, which may be browsed here: Browser API Web-Page

    Node.js RDP-API Implementation:
    You may read about the Node.js Chrome Remote Interface on the Node.js Package Manager Web-Site: NPM
    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.

    This class is intended to be used with a Headless Browser

    These methods have been tested, to some degree, using Google Chrome. In order to use this class you must start a web-browser instance and make a connection to the browser using a Remote Debugging Port. The initializations may be accomplished using class BRDPC (Browser Remote Debug Protocol Connection).

    Google-Chrome was used during the development process of the classes in this particular package. Note that, lately, it has been asserted Microsoft has switched to using the Chrome-Engine for its Microsoft Edge Browser Internal Code-Base. Therefore, there may limited support / functionality when running the methods in this class with Microsoft-Edge. There is the possibility these will work with Opera & Safari.

    Check whether the your Web-Browser will allow itself to be driven by the Web-Socket RDP-Port 9223.


    Foreign Function API:
    Every one of the methods that reside in this class are designed to do nothing more than:

    1. Accept Parameters from the User, and "Marshall Them" into a Valid JSON-Request
    2. Transmit the Marshalled Request-JSON to a Headless Web-Browser over a Web-Socket RDP Connection
    3. Receive BOTH that Method's Results AND any Browser Event-Firings from the Web-Socket
    4. Parse JSON Method-Results and Browser-Event Firings, and Subsequently Convert them to Standard Java-Types
    5. Report these Method-Results and Browser-Events to the User via an User-Registered Event-Listener or a Promise Object


    Java-HTML Difference:
    Unlike the bulk of the Java HTML JAR Library, there is very little native Java-Code, and very little testing that may be done on any of the classes & methods in this package. The code inside these classes does nothing more than marshall-and-unmarshall Java-Types into Json-Requests (and vice-versa). The Java-Script & Browser modules inside of a Google-Chrome instance are, theoretically, handling these requests, and returning their results (or events) over the Web-Socket Connection.

    It has been asserted (by Google Chrome Developers) that some of these methods are only "partially working" or "experimental".



    Stateless Class:
    This class neither contains any program-state, nor can it be instantiated. The @StaticFunctional Annotation may also be called 'The Spaghetti Report'. Static-Functional classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's @Stateless Annotation.

    • 1 Constructor(s), 1 declared private, zero-argument constructor
    • 33 Method(s), 33 declared static
    • 27 Field(s), 27 declared static, 26 declared final
    • Fields excused from final modifier (with explanation):
      Field 'counter' is not final. Reason: CONFIGURATION


    • Field Detail

      • ResourceType

        public static final java.lang.String[] ResourceType
        Resource type as it was perceived by the rendering engine.
        Code:
        Exact Field Declaration Expression:
         public static final String[] ResourceType =
             { 
                 "Document", "Stylesheet", "Image", "Media", "Font", "Script", "TextTrack", "XHR", "Fetch", 
                 "EventSource", "WebSocket", "Manifest", "SignedExchange", "Ping", "CSPViolationReport", 
                 "Preflight", "Other", 
             };
        
      • ErrorReason

        public static final java.lang.String[] ErrorReason
        Network level fetch failure reason.
        Code:
        Exact Field Declaration Expression:
         public static final String[] ErrorReason =
             { 
                 "Failed", "Aborted", "TimedOut", "AccessDenied", "ConnectionClosed", "ConnectionReset", 
                 "ConnectionRefused", "ConnectionAborted", "ConnectionFailed", "NameNotResolved", 
                 "InternetDisconnected", "AddressUnreachable", "BlockedByClient", "BlockedByResponse", 
             };
        
      • ConnectionType

        public static final java.lang.String[] ConnectionType
        The underlying connection technology that the browser is supposedly using.
        Code:
        Exact Field Declaration Expression:
         public static final String[] ConnectionType =
             { 
                 "none", "cellular2g", "cellular3g", "cellular4g", "bluetooth", "ethernet", "wifi", "wimax", 
                 "other", 
             };
        
      • CookiePriority

        public static final java.lang.String[] CookiePriority
        Represents the cookie's 'Priority' status: https://tools.ietf.org/html/draft-west-cookie-priority-00

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] CookiePriority =
             { "Low", "Medium", "High", };
        
      • CookieSourceScheme

        public static final java.lang.String[] CookieSourceScheme
        Represents the source scheme of the origin that originally set the cookie. A value of "Unset" allows protocol clients to emulate legacy cookie scope for the scheme. This is a temporary ability and it will be removed in the future.

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] CookieSourceScheme =
             { "Unset", "NonSecure", "Secure", };
        
      • BlockedReason

        public static final java.lang.String[] BlockedReason
        The reason why request was blocked.
        Code:
        Exact Field Declaration Expression:
         public static final String[] BlockedReason =
             { 
                 "other", "csp", "mixed-content", "origin", "inspector", "subresource-filter", 
                 "content-type", "coep-frame-resource-needs-coep-header", 
                 "coop-sandboxed-iframe-cannot-navigate-to-coop-page", "corp-not-same-origin", 
                 "corp-not-same-origin-after-defaulted-to-same-origin-by-coep", "corp-not-same-site", 
             };
        
      • CorsError

        public static final java.lang.String[] CorsError
        The reason why request was blocked.
        Code:
        Exact Field Declaration Expression:
         public static final String[] CorsError =
             { 
                 "DisallowedByMode", "InvalidResponse", "WildcardOriginNotAllowed", 
                 "MissingAllowOriginHeader", "MultipleAllowOriginValues", "InvalidAllowOriginValue", 
                 "AllowOriginMismatch", "InvalidAllowCredentials", "CorsDisabledScheme", 
                 "PreflightInvalidStatus", "PreflightDisallowedRedirect", 
                 "PreflightWildcardOriginNotAllowed", "PreflightMissingAllowOriginHeader", 
                 "PreflightMultipleAllowOriginValues", "PreflightInvalidAllowOriginValue", 
                 "PreflightAllowOriginMismatch", "PreflightInvalidAllowCredentials", 
                 "PreflightMissingAllowExternal", "PreflightInvalidAllowExternal", 
                 "InvalidAllowMethodsPreflightResponse", "InvalidAllowHeadersPreflightResponse", 
                 "MethodDisallowedByPreflightResponse", "HeaderDisallowedByPreflightResponse", 
                 "RedirectContainsCredentials", "InsecurePrivateNetwork", "InvalidPrivateNetworkAccess", 
                 "UnexpectedPrivateNetworkAccess", "NoCorsRedirectModeNotFollow", 
             };
        
      • SetCookieBlockedReason

        public static final java.lang.String[] SetCookieBlockedReason
        Types of reasons why a cookie may not be stored from a response.

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] SetCookieBlockedReason =
             { 
                 "SecureOnly", "SameSiteStrict", "SameSiteLax", "SameSiteUnspecifiedTreatedAsLax", 
                 "SameSiteNoneInsecure", "UserPreferences", "SyntaxError", "SchemeNotSupported", 
                 "OverwriteSecure", "InvalidDomain", "InvalidPrefix", "UnknownError", 
                 "SchemefulSameSiteStrict", "SchemefulSameSiteLax", 
                 "SchemefulSameSiteUnspecifiedTreatedAsLax", "SamePartyFromCrossPartyContext", 
                 "SamePartyConflictsWithOtherAttributes", "NameValuePairExceedsMaxSize", 
             };
        
      • CookieBlockedReason

        public static final java.lang.String[] CookieBlockedReason
        Types of reasons why a cookie may not be sent with a request.

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] CookieBlockedReason =
             { 
                 "SecureOnly", "NotOnPath", "DomainMismatch", "SameSiteStrict", "SameSiteLax", 
                 "SameSiteUnspecifiedTreatedAsLax", "SameSiteNoneInsecure", "UserPreferences", 
                 "UnknownError", "SchemefulSameSiteStrict", "SchemefulSameSiteLax", 
                 "SchemefulSameSiteUnspecifiedTreatedAsLax", "SamePartyFromCrossPartyContext", 
                 "NameValuePairExceedsMaxSize", 
             };
        
      • InterceptionStage

        public static final java.lang.String[] InterceptionStage
        Stages of the interception to begin intercepting. Request will intercept before the request is sent. Response will intercept after the response is received.

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] InterceptionStage =
             { "Request", "HeadersReceived", };
        
      • SignedExchangeErrorField

        public static final java.lang.String[] SignedExchangeErrorField
        Field type for a signed exchange related error.

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] SignedExchangeErrorField =
             { 
                 "signatureSig", "signatureIntegrity", "signatureCertUrl", "signatureCertSha256", 
                 "signatureValidityUrl", "signatureTimestamps", 
             };
        
      • PrivateNetworkRequestPolicy

        public static final java.lang.String[] PrivateNetworkRequestPolicy
        [No Description Provided by Google]

        EXPERIMENTAL
        Code:
        Exact Field Declaration Expression:
         public static final String[] PrivateNetworkRequestPolicy =
             { 
                 "Allow", "BlockFromInsecureToMorePrivate", "WarnFromInsecureToMorePrivate", 
                 "PreflightBlock", "PreflightWarn", 
             };
        
    • Method Detail

      • setAcceptedEncodings

        public static Script<java.lang.String,​JsonObject,​Ret0setAcceptedEncodings​
                    (java.lang.String[] encodings)
        
        Sets a list of content encodings that will be accepted. Empty list means no encoding is accepted.
        EXPERIMENTAL
        Parameters:
        encodings - List of accepted content encodings.
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • continueInterceptedRequest

        public static Script<java.lang.String,​JsonObject,​Ret0continueInterceptedRequest​
                    (java.lang.String interceptionId,
                     java.lang.String errorReason,
                     java.lang.String rawResponse,
                     java.lang.String url,
                     java.lang.String method,
                     java.lang.String postData,
                     JsonObject headers,
                     Network.AuthChallengeResponse authChallengeResponse)
        
        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. Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead.
        EXPERIMENTAL
        DEPRECATED
        Parameters:
        interceptionId - -
        errorReason - 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.
        OPTIONAL
        rawResponse - 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. (Encoded as a base64 string when passed over JSON)
        OPTIONAL
        url - 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.
        OPTIONAL
        method - If set this allows the request method to be overridden. Must not be set in response to an authChallenge.
        OPTIONAL
        postData - If set this allows postData to be set. Must not be set in response to an authChallenge.
        OPTIONAL
        headers - If set this allows the request headers to be changed. Must not be set in response to an authChallenge.
        OPTIONAL
        authChallengeResponse - Response to a requestIntercepted with an authChallenge. Must not be set otherwise.
        OPTIONAL
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • deleteCookies

        public static Script<java.lang.String,​JsonObject,​Ret0deleteCookies​
                    (java.lang.String name,
                     java.lang.String url,
                     java.lang.String domain,
                     java.lang.String path)
        
        Deletes browser cookies with matching name and url or domain/path pair.
        Parameters:
        name - Name of the cookies to remove.
        url - If specified, deletes all the cookies with the given name where domain and path match provided URL.
        OPTIONAL
        domain - If specified, deletes only cookies with the exact domain.
        OPTIONAL
        path - If specified, deletes only cookies with the exact path.
        OPTIONAL
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • emulateNetworkConditions

        public static Script<java.lang.String,​JsonObject,​Ret0emulateNetworkConditions​
                    (boolean offline,
                     java.lang.Number latency,
                     java.lang.Number downloadThroughput,
                     java.lang.Number uploadThroughput,
                     java.lang.String connectionType)
        
        Activates emulation of network conditions.
        Parameters:
        offline - True to emulate internet disconnection.
        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.
        connectionType - Connection type if known.
        OPTIONAL
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • enable

        public static Script<java.lang.String,​JsonObject,​Ret0enable​
                    (java.lang.Integer maxTotalBufferSize,
                     java.lang.Integer maxResourceBufferSize,
                     java.lang.Integer maxPostDataSize)
        
        Enables network tracking, network events will now be delivered to the client.
        Parameters:
        maxTotalBufferSize - Buffer size in bytes to use when preserving network payloads (XHRs, etc).
        OPTIONAL
        EXPERIMENTAL
        maxResourceBufferSize - Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).
        OPTIONAL
        EXPERIMENTAL
        maxPostDataSize - Longest post body size (in bytes) that would be included in requestWillBeSent notification
        OPTIONAL
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • getCookies

        public static Script<java.lang.String,​JsonObject,​Network.Cookie[]> getCookies​
                    (java.lang.String[] urls)
        
        Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.
        Parameters:
        urls - The list of URLs for which applicable cookies will be fetched. If not specified, it's assumed to be set to the list containing the URLs of the page and all of its subframes.
        OPTIONAL
        Returns:
        An instance of Script<String, JsonObject, Network.Cookie[]>

        This script may be executed, using Script.exec(), and afterwards, a Promise<JsonObject, Network.Cookie[]> will be returned.

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may may be retrieved.

        This Browser Function returns

      • getRequestPostData

        public static Script<java.lang.String,​JsonObject,​java.lang.String> getRequestPostData​
                    (java.lang.String requestId)
        
        Returns post data sent with the request. Returns an error when no data was sent with the request.
        Parameters:
        requestId - Identifier of the network request to get content for.
        Returns:
        An instance of Script<String, JsonObject, String>

        This script may be executed, using Script.exec(), and afterwards, a Promise<JsonObject, String> will be returned.

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may may be retrieved.

        This Browser Function returns

        • String (postData)
          Request body string, omitting files from multipart requests
      • takeResponseBodyForInterceptionAsStream

        public static Script<java.lang.String,​JsonObject,​java.lang.String> takeResponseBodyForInterceptionAsStream​
                    (java.lang.String interceptionId)
        
        Returns a handle to the stream representing the response body. Note that after this command, the intercepted request can't be continued as is -- you either need to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified.
        EXPERIMENTAL
        Parameters:
        interceptionId - -
        Returns:
        An instance of Script<String, JsonObject, String>

        This script may be executed, using Script.exec(), and afterwards, a Promise<JsonObject, String> will be returned.

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may may be retrieved.

        This Browser Function returns

        • String (stream)
          -
      • replayXHR

        public static Script<java.lang.String,​JsonObject,​Ret0replayXHR​
                    (java.lang.String requestId)
        
        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.
        EXPERIMENTAL
        Parameters:
        requestId - Identifier of XHR to replay.
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • setBlockedURLs

        public static Script<java.lang.String,​JsonObject,​Ret0setBlockedURLs​
                    (java.lang.String[] urls)
        
        Blocks URLs from loading.
        EXPERIMENTAL
        Parameters:
        urls - URL patterns to block. Wildcards ('*') are allowed.
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • setCacheDisabled

        public static Script<java.lang.String,​JsonObject,​Ret0setCacheDisabled​
                    (boolean cacheDisabled)
        
        Toggles ignoring cache for each request. If true, cache will not be used.
        Parameters:
        cacheDisabled - Cache disabled state.
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • setCookie

        public static Script<java.lang.String,​JsonObject,​java.lang.Boolean> setCookie​
                    (java.lang.String name,
                     java.lang.String value,
                     java.lang.String url,
                     java.lang.String domain,
                     java.lang.String path,
                     java.lang.Boolean secure,
                     java.lang.Boolean httpOnly,
                     java.lang.String sameSite,
                     java.lang.Number expires,
                     java.lang.String priority,
                     java.lang.Boolean sameParty,
                     java.lang.String sourceScheme,
                     java.lang.Integer sourcePort)
        
        Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
        Parameters:
        name - Cookie name.
        value - Cookie value.
        url - The request-URI to associate with the setting of the cookie. This value can affect the default domain, path, source port, and source scheme values of the created cookie.
        OPTIONAL
        domain - Cookie domain.
        OPTIONAL
        path - Cookie path.
        OPTIONAL
        secure - True if cookie is secure.
        OPTIONAL
        httpOnly - True if cookie is http-only.
        OPTIONAL
        sameSite - Cookie SameSite type.
        OPTIONAL
        expires - Cookie expiration date, session cookie if not set
        OPTIONAL
        priority - Cookie Priority type.
        OPTIONAL
        EXPERIMENTAL
        sameParty - True if cookie is SameParty.
        OPTIONAL
        EXPERIMENTAL
        sourceScheme - Cookie source scheme type.
        OPTIONAL
        EXPERIMENTAL
        sourcePort - Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port. An unspecified port value allows protocol clients to emulate legacy cookie scope for the port. This is a temporary ability and it will be removed in the future.
        OPTIONAL
        EXPERIMENTAL
        Returns:
        An instance of Script<String, JsonObject, Boolean>

        This script may be executed, using Script.exec(), and afterwards, a Promise<JsonObject, Boolean> will be returned.

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may may be retrieved.

        This Browser Function returns

        • Boolean (success)
          Always set to true. If an error occurs, the response indicates protocol error.
      • setAttachDebugStack

        public static Script<java.lang.String,​JsonObject,​Ret0setAttachDebugStack​
                    (boolean enabled)
        
        Specifies whether to attach a page script stack id in requests
        EXPERIMENTAL
        Parameters:
        enabled - Whether to attach a page script stack for debugging purpose.
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • setRequestInterception

        public static Script<java.lang.String,​JsonObject,​Ret0setRequestInterception​
                    (Network.RequestPattern[] patterns)
        
        Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead.
        EXPERIMENTAL
        DEPRECATED
        Parameters:
        patterns - Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • setUserAgentOverride

        public static Script<java.lang.String,​JsonObject,​Ret0setUserAgentOverride​
                    (java.lang.String userAgent,
                     java.lang.String acceptLanguage,
                     java.lang.String platform,
                     Emulation.UserAgentMetadata userAgentMetadata)
        
        Allows overriding user agent with the given string.
        Parameters:
        userAgent - User agent to use.
        acceptLanguage - Browser langugage to emulate.
        OPTIONAL
        platform - The platform navigator.platform should return.
        OPTIONAL
        userAgentMetadata - To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
        OPTIONAL
        EXPERIMENTAL
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.
      • enableReportingApi

        public static Script<java.lang.String,​JsonObject,​Ret0enableReportingApi​
                    (boolean enable)
        
        Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client. Enabling triggers 'reportingApiReportAdded' for all existing reports.
        EXPERIMENTAL
        Parameters:
        enable - Whether to enable or disable events for the Reporting API
        Returns:
        An instance of Script<String, JsonObject, Ret0>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<JsonObject, Ret0 > to ensure the Browser Function has run to completion.