
    >i|                    d   d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! erXd dl"m#Z# d dlm$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA d dlBmCZCmDZDmEZEmFZFmGZGmHZHmIZI  G d d	      ZJy
)    )annotations)TYPE_CHECKINGOptional)Command)DeleteCookiesParamsEmulateNetworkConditionsParamsEnableReportingApiParamsGetCertificateParamsGetCookiesParamsGetRequestPostDataParams$GetResponseBodyForInterceptionParamsGetResponseBodyParams GetSecurityIsolationStatusParamsLoadNetworkResourceParamsNetworkEnableParamsNetworkMethodReplayXHRParamsSearchInResponseBodyParamsSetAcceptedEncodingsParamsSetAttachDebugStackParamsSetBlockedURLsParamsSetBypassServiceWorkerParamsSetCacheDisabledParamsSetCookieControlsParamsSetCookieParamsSetCookiesParamsSetExtraHTTPHeadersParamsSetUserAgentOverrideParamsStreamResourceContentParams-TakeResponseBodyForInterceptionAsStreamParams)UserAgentMetadata)%ClearAcceptedEncodingsOverrideCommandClearBrowserCacheCommandClearBrowserCookiesCommandClearCookiesCommandDisableCommandEmulateNetworkConditionsCommandEnableCommandEnableReportingApiCommandGetCertificateCommandGetCookiesCommandGetRequestPostDataCommandGetResponseBodyCommand%GetResponseBodyForInterceptionCommand!GetSecurityIsolationStatusCommandHeaderEntryLoadNetworkResourceCommandReplayXHRCommandSearchInResponseBodyCommandSetAcceptedEncodingsCommandSetAttachDebugStackCommandSetBlockedURLsCommandSetBypassServiceWorkerCommandSetCacheDisabledCommandSetCookieCommandSetCookieControlsCommandSetCookiesCommandSetExtraHTTPHeadersCommandSetUserAgentOverrideCommandStreamResourceContentCommand.TakeResponseBodyForInterceptionAsStreamCommand)ConnectionTypeContentEncodingCookiePartitionKeyCookiePriorityCookieSameSiteCookieSourceSchemeLoadNetworkResourceOptionsc                     e Zd ZdZed d       Zed!d       Ze	 	 	 	 d"	 	 	 	 	 	 	 	 	 	 	 d#d       Zed$d       Ze	 	 	 d%	 	 	 	 	 	 	 d&d       Z	e	 d'	 	 	 d(d       Z
e	 	 	 	 d)d	       Ze	 	 	 	 d*d
       Zed+d       Ze	 	 	 	 	 	 	 	 	 	 	 	 d,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-d       Zed.d       Ze	 	 	 	 d/d       Ze	 	 	 d%	 	 	 	 	 	 	 	 	 d0d       Zed1d       Ze	 	 	 	 d2d       Ze	 	 d3	 	 	 	 	 	 	 	 	 d4d       Zed5d       Ze	 	 	 	 d6d       Zed7d       Ze	 	 	 	 d8d       Ze	 	 	 	 d9d       Zed:d       Ze	 	 d;	 	 	 	 	 	 	 d<d       Ze	 	 	 	 d=d       Ze	 	 	 	 d>d       Ze	 	 	 	 d"	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d?d       Ze	 d'	 	 	 d@d       Ze	 d'	 	 	 	 	 	 	 dAd       Z e	 	 	 	 dBd       Z!y)CNetworkCommandsa  
    Implementation of Chrome DevTools Protocol for the Network domain.

    This class provides commands for monitoring and manipulating network activities,
    enabling detailed inspection and control over HTTP requests and responses.
    The Network domain exposes comprehensive network-related information including:
    - Request/response headers and bodies
    - Resource timing and caching behavior
    - Cookie management and security details
    - Network conditions emulation
    - Traffic interception and modification

    The commands allow developers to analyze performance, debug network issues,
    and test application behavior under various network conditions.
    c                 6    t        t        j                        S )a)  
        Clears browser cache storage.

        This command is essential for testing cache behavior and ensuring fresh
        resource loading. It affects all cached resources including:
        - CSS/JavaScript files
        - Images and media assets
        - API response caching

        Use cases:
        - Testing cache invalidation strategies
        - Reproducing issues with stale content
        - Performance benchmarking without cache influence

        Returns:
            Command: CDP command to clear the entire browser cache
        method)r   r   CLEAR_BROWSER_CACHE     f/var/www/python/tenders/Scrapper/venv/lib/python3.12/site-packages/pydoll/commands/network_commands.pyclear_browser_cachez#NetworkCommands.clear_browser_cachea   s    & m??@@rN   c                 6    t        t        j                        S )ao  
        Command to clear all cookies stored in the browser.

        This can be beneficial for testing scenarios where you need
        to simulate a fresh user session without any previously stored
        cookies that might affect the application's behavior.

        Returns:
            Command[Response]: A command to clear all cookies in the browser.
        rJ   )r   r   CLEAR_BROWSER_COOKIESrM   rN   rO   clear_browser_cookiesz%NetworkCommands.clear_browser_cookiesv   s     mAABBrN   Nc                    t        |       }|||d<   |||d<   |||d<   |||d<   t        t        j                  |      S )a  
        Deletes browser cookies with matching criteria.

        Provides granular control over cookie removal through multiple parameters:
        - Delete by name only (affects all matching cookies)
        - Scope deletion using URL, domain, or path
        - Handle partitioned cookies for privacy-aware applications

        Args:
            name: Name of the cookies to remove (required)
            url: Delete cookies for specific URL (domain/path must match)
            domain: Exact domain for cookie deletion
            path: Exact path for cookie deletion
            partition_key: Partition key attributes for cookie isolation

        Returns:
            Command: CDP command to execute selective cookie deletion
        )nameurldomainpathpartitionKeyrK   params)r   r   r   DELETE_COOKIES)rU   rV   rW   rX   partition_keyr[   s         rO   delete_cookieszNetworkCommands.delete_cookies   s^    4 %$/?F5M%F8!F6N$%2F>"m::6JJrN   c                 6    t        t        j                        S )a  
        Stops network monitoring and event reporting.

        Preserves network state but stops:
        - Request/response events
        - WebSocket message tracking
        - Loading progress notifications

        Use when:
        - Reducing overhead during non-network operations
        - Pausing monitoring temporarily
        - Finalizing network-related tests

        Returns:
            Command: CDP command to disable network monitoring
        rJ   )r   r   DISABLErM   rN   rO   disablezNetworkCommands.disable   s    $ m3344rN   c                v    t               }| | |d<   |||d<   |||d<   t        t        j                  |      S )a7  
        Enables network monitoring with configurable buffers.

        Args:
            max_total_buffer_size: Total memory buffer for network data (bytes)
            max_resource_buffer_size: Per-resource buffer limit (bytes)
            max_post_data_size: Maximum POST payload to capture (bytes)

        Recommended settings:
        - Increase buffers for long-running sessions
        - Adjust post size for API testing
        - Monitor memory usage with large buffers

        Returns:
            Command: CDP command to enable network monitoring
        maxTotalBufferSizemaxResourceBufferSizemaxPostDataSizerZ   )r   r   r   ENABLE)max_total_buffer_sizemax_resource_buffer_sizemax_post_data_sizer[   s       rO   enablezNetworkCommands.enable   sR    , %& ,+@F'(#/.FF*+)(:F$%m226BBrN   c                Z    t               }| | |d<   t        t        j                  |      S )a  
        Retrieves cookies matching specified URLs.

        Args:
            urls: list of URLs to scope cookie retrieval

        Returns:
            Command: CDP command returning cookie details including:
                - Name, value, and attributes
                - Security and scope parameters
                - Expiration and size information

        Usage notes:
        - Empty URL list returns all cookies
        - Includes HTTP-only and secure cookies
        - Shows partitioned cookie status
        urlsrZ   )r   r   r   GET_COOKIESrl   r[   s     rO   get_cookieszNetworkCommands.get_cookies   s.    * "#!F6Nm77GGrN   c                P    t        |       }t        t        j                  |      S )aQ  
        Retrieves POST data from a specific network request.

        Essential for:
        - Form submission analysis
        - API request debugging
        - File upload monitoring
        - Security testing

        Args:
            request_id: Unique identifier for the network request

        Returns:
            Command: CDP command that returns:
                - Raw POST data content
                - Multipart form data (excluding file contents)
                - Content encoding information

        Note: Large POST bodies may be truncated based on buffer settings
        	requestIdrZ   )r   r   r   GET_REQUEST_POST_DATA
request_idr[   s     rO   get_request_post_dataz%NetworkCommands.get_request_post_data   s!    0 *J?mAA&QQrN   c                P    t        |       }t        t        j                  |      S )as  
        Retrieves the full content of a network response.

        Supports various content types:
        - Text-based resources (HTML, CSS, JSON)
        - Base64-encoded binary content (images, media)
        - Gzip/deflate compressed responses

        Args:
            request_id: Unique network request identifier

        Important considerations:
        - Response must be available in browser memory
        - Large responses may require streaming approaches
        - Sensitive data should be handled securely

        Returns:
            Command: CDP command returning response body and encoding details
        rq   rZ   )r   r   r   GET_RESPONSE_BODYrt   s     rO   get_response_bodyz!NetworkCommands.get_response_body  s!    . '<m==fMMrN   c                P    t        |       }t        t        j                  |      S )a  
        Controls browser's cache mechanism.

        Use cases:
        - Testing resource update behavior
        - Forcing fresh content loading
        - Performance impact analysis
        - Cache-busting scenarios

        Args:
            cache_disabled: True to disable caching, False to enable

        Returns:
            Command: CDP command to modify cache behavior

        Note: Affects all requests until re-enabled
        )cacheDisabledrZ   )r   r   r   SET_CACHE_DISABLED)cache_disabledr[   s     rO   set_cache_disabledz"NetworkCommands.set_cache_disabled+  s!    & (nEm>>vNNrN   c                    t        | |      }|||d<   |||d<   |||d<   |||d<   |||d<   |||d<   |||d<   |	|	|d	<   |
|
|d
<   |||d<   |||d<   |||d<   t        t        j                  |      S )aw  
        Creates or updates a cookie with specified attributes.

        Comprehensive cookie control supporting:
        - Session and persistent cookies
        - Security attributes (Secure, HttpOnly)
        - SameSite policies
        - Cookie partitioning
        - Priority levels

        Args:
            name: Cookie name
            value: Cookie value
            url: Target URL for the cookie
            domain: Cookie domain scope
            path: Cookie path scope
            secure: Require HTTPS
            http_only: Prevent JavaScript access
            same_site: Cross-site access policy
            expires: Expiration timestamp
            priority: Cookie priority level
            same_party: First-Party Sets flag
            source_scheme: Cookie source context
            source_port: Source port restriction
            partition_key: Storage partition key

        Returns:
            Command: CDP command that returns success status

        Security considerations:
        - Use secure flag for sensitive data
        - Consider SameSite policies
        - Be aware of cross-site implications
        )rU   valuerV   rW   rX   securehttpOnlysameSiteexpirespriority	samePartysourceScheme
sourcePortrY   rZ   )r   r   r   
SET_COOKIE)rU   r   rV   rW   rX   r   	http_only	same_siter   r   
same_partysource_schemesource_portr]   r[   s                  rO   
set_cookiezNetworkCommands.set_cookieA  s    f !d%8?F5M%F8!F6N%F8 !*F: !*F: 'F9!)F:!",F;$%2F>""#.F< $%2F>"m66vFFrN   c                P    t        |       }t        t        j                  |      S )a;  
        Sets multiple cookies in a single operation.

        Efficient for:
        - Batch cookie operations
        - Session state restoration
        - Testing multiple authentication states
        - Cross-domain cookie setup

        Args:
            cookies: list of cookie parameters including
                    name, value, and attributes

        Returns:
            Command: CDP command for bulk cookie setting

        Performance note:
        - More efficient than multiple set_cookie calls
        - Consider memory impact with large batches
        )cookiesrZ   )r   r   r   SET_COOKIES)r   r[   s     rO   set_cookieszNetworkCommands.set_cookies  s!    , "'2m77GGrN   c                P    t        |       }t        t        j                  |      S )ab  
        Applies custom HTTP headers to all subsequent requests.

        Enables advanced scenarios:
        - A/B testing with custom headers
        - Authentication bypass for testing
        - Content negotiation simulations
        - Security header validation

        Args:
            headers: list of key-value header pairs

        Security notes:
        - Headers are applied browser-wide
        - Sensitive headers (e.g., Authorization) persist until cleared
        - Use with caution in shared environments

        Returns:
            Command: CDP command to set global HTTP headers
        )headersrZ   )r   r   r   SET_EXTRA_HTTP_HEADERS)r   r[   s     rO   set_extra_http_headersz&NetworkCommands.set_extra_http_headers  s!    0 +7;mBB6RRrN   c                z    t        |       }|||d<   |||d<   |||d<   t        t        j                  |      S )a  
        Overrides the browser's User-Agent string.

        Use cases:
        - Device/browser simulation
        - Compatibility testing
        - Content negotiation
        - Bot detection bypass

        Args:
            user_agent: Complete User-Agent string
            accept_language: Language preference header
            platform: Platform identifier
            user_agent_metadata: Detailed UA metadata

        Returns:
            Command: CDP command to override user agent

        Testing considerations:
        - Affects all subsequent requests
        - May impact server-side behavior
        - Consider mobile/desktop differences
        )	userAgentacceptLanguageplatformuserAgentMetadatarZ   )r   r   r   SET_USER_AGENT_OVERRIDE)
user_agentaccept_languager   user_agent_metadatar[   s        rO   set_useragent_overridez&NetworkCommands.set_useragent_override  sS    < ,jA&'6F#$!)F:**=F&'mCCFSSrN   c                 6    t        t        j                        S )a  
        Restores default content encoding acceptance.

        Effects:
        - Resets compression preferences
        - Restores default Accept-Encoding header
        - Allows server-chosen encoding

        Use when:
        - Testing encoding fallbacks
        - Debugging compression issues
        - Resetting after encoding tests

        Returns:
            Command: CDP command to clear encoding overrides
        rJ   )r   r   !CLEAR_ACCEPTED_ENCODINGS_OVERRIDErM   rN   rO   !clear_accepted_encodings_overridez1NetworkCommands.clear_accepted_encodings_override  s    $ mMMNNrN   c                P    t        |       }t        t        j                  |      S )a  
        Controls the Reporting API functionality.

        Features:
        - Network error reporting
        - Deprecation notices
        - CSP violation reports
        - CORS issues

        Args:
            enabled: True to enable, False to disable

        Returns:
            Command: CDP command to configure Reporting API

        Note: Requires browser support for Reporting API
        enabledrZ   )r	   r   r   ENABLE_REPORTING_APIr   r[   s     rO   enable_reporting_apiz$NetworkCommands.enable_reporting_api   s!    * *':m@@PPrN   c                n    t        | |      }|||d<   |||d<   t        t        j                  |      S )a[  
        Searches for content within response bodies.

        Powerful for:
        - Content verification
        - Security scanning
        - Data extraction
        - Response validation

        Args:
            request_id: Target response identifier
            query: Search string or pattern
            case_sensitive: Match case sensitivity
            is_regex: Use regular expression matching

        Returns:
            Command: CDP command returning match results

        Performance tip:
        - Use specific queries for large responses
        - Consider regex complexity
        )rr   querycaseSensitiveisRegexrZ   )r   r   r   SEARCH_IN_RESPONSE_BODY)ru   r   case_sensitiveis_regexr[   s        rO   search_in_response_bodyz'NetworkCommands.search_in_response_body  sC    : ,jN%&4F?# (F9mCCFSSrN   c                P    t        |       }t        t        j                  |      S )aG  
        Blocks specified URLs from loading.

        Key features:
        - Pattern-based URL blocking
        - Resource type filtering
        - Network request prevention
        - Error simulation

        Args:
            urls: list of URL patterns to block
                 Supports wildcards and pattern matching

        Returns:
            Command: CDP command to set URL blocking rules

        Common applications:
        - Ad/tracker blocking simulation
        - Resource loading control
        - Error handling testing
        - Network isolation testing
        )rl   rZ   )r   r   r   SET_BLOCKED_URLSrn   s     rO   set_blocked_urlsz NetworkCommands.set_blocked_urls<  s!    0 &40m<<VLLrN   c                P    t        |       }t        t        j                  |      S )a  
        Controls Service Worker interception of network requests.

        Use cases:
        - Testing direct network behavior
        - Bypassing offline functionality
        - Debug caching issues
        - Performance comparison

        Args:
            bypass: True to skip Service Worker, False to allow

        Returns:
            Command: CDP command to configure Service Worker behavior

        Impact:
        - Affects offline capabilities
        - Changes caching behavior
        - Modifies push notifications
        )bypassrZ   )r   r   r   SET_BYPASS_SERVICE_WORKER)r   r[   s     rO   set_bypass_service_workerz)NetworkCommands.set_bypass_service_workerW  s!    0 .V<mEEfUUrN   c                P    t        |       }t        t        j                  |      S )a  
        Retrieves SSL/TLS certificate information for a domain.

        Provides:
        - Certificate chain details
        - Validation status
        - Expiration information
        - Issuer details

        Args:
            origin: Target domain for certificate inspection

        Returns:
            Command: CDP command returning certificate data

        Security applications:
        - Certificate validation
        - SSL/TLS verification
        - Security assessment
        - Chain of trust verification
        )originrZ   )r
   r   r   GET_CERTIFICATE)r   r[   s     rO   get_certificatezNetworkCommands.get_certificater  s!    . &V4m;;FKKrN   c                P    t        |       }t        t        j                  |      S )a  
        Retrieves response body from an intercepted request.

        Essential for:
        - Response modification
        - Content inspection
        - Security testing
        - API response validation

        Args:
            interception_id: Identifier for intercepted request

        Returns:
            Command: CDP command providing intercepted response content

        Note:
        - Must be used with interception enabled
        - Supports streaming responses
        - Handles various content types
        interceptionIdrZ   )r   r   r   "GET_RESPONSE_BODY_FOR_INTERCEPTIONinterception_idr[   s     rO   "get_response_body_for_interceptionz2NetworkCommands.get_response_body_for_interception  s"    0 6_UmNNW]^^rN   c                P    t        |       }t        t        j                  |      S )a   
        Specifies accepted content encodings for requests.

        Controls:
        - Compression algorithms
        - Transfer encoding
        - Content optimization

        Args:
            encodings: list of accepted encoding methods
                     (gzip, deflate, br, etc.)

        Returns:
            Command: CDP command to set encoding preferences

        Performance implications:
        - Affects bandwidth usage
        - Impacts response time
        - Changes server behavior
        )	encodingsrZ   )r   r   r   SET_ACCEPTED_ENCODINGS)r   r[   s     rO   set_accepted_encodingsz&NetworkCommands.set_accepted_encodings  s!    0 ,i@mBB6RRrN   c                P    t        |       }t        t        j                  |      S )a!  
        Enables/disables debug stack attachment to requests.

        Debug features:
        - Stack trace collection
        - Request origin tracking
        - Initialization context
        - Call site identification

        Args:
            enabled: True to attach debug info, False to disable

        Returns:
            Command: CDP command to configure debug stack attachment

        Performance note:
        - May impact performance when enabled
        - Useful for development/debugging
        - Consider memory usage
        r   rZ   )r   r   r   SET_ATTACH_DEBUG_STACKr   s     rO   set_attach_debug_stackz&NetworkCommands.set_attach_debug_stack  s!    , +7;mBB6RRrN   c                l    t        |       }|||d<   |||d<   t        t        j                  |      S )a  
        Configures third-party cookie handling policies.

        Privacy features:
        - Cookie access control
        - Third-party restrictions
        - Tracking prevention
        - Privacy policy enforcement

        Args:
            enable_third_party_cookie_restriction: Enable restrictions
            disable_third_party_cookie_metadata: Skip metadata checks
            disable_third_party_cookie_heuristics: Disable detection logic

        Returns:
            Command: CDP command to set cookie control policies

        Security implications:
        - Affects cross-site tracking
        - Changes authentication behavior
        - Impacts embedded content
        )!enableThirdPartyCookieRestrictiondisableThirdPartyCookieMetadata!disableThirdPartyCookieHeuristicsrZ   )r   r   r   SET_COOKIE_CONTROLS)%enable_third_party_cookie_restriction#disable_third_party_cookie_metadata%disable_third_party_cookie_heuristicsr[   s       rO   set_cookie_controlsz#NetworkCommands.set_cookie_controls  sH    8 ).S
 /:8[F450<:_F67m??OOrN   c                P    t        |       }t        t        j                  |      S )a  
        Enables streaming of response content.

        Useful for:
        - Large file downloads
        - Progressive loading
        - Memory optimization
        - Real-time processing

        Args:
            request_id: Target request identifier

        Returns:
            Command: CDP command to initiate content streaming

        Best practices:
        - Monitor memory usage
        - Handle stream chunks efficiently
        - Consider error recovery
        rq   rZ   )r   r   r   STREAM_RESOURCE_CONTENTrt   s     rO   stream_resource_contentz'NetworkCommands.stream_resource_content   s!    0 -zBmCCFSSrN   c                P    t        |       }t        t        j                  |      S )a  
        Creates a stream for intercepted response body.

        Applications:
        - Large response handling
        - Content modification
        - Bandwidth optimization
        - Progressive processing

        Args:
            interception_id: Intercepted response identifier

        Returns:
            Command: CDP command returning stream handle

        Stream handling:
        - Supports chunked transfer
        - Manages memory efficiently
        - Enables real-time processing
        r   rZ   )r    r   r   -TAKE_RESPONSE_BODY_FOR_INTERCEPTION_AS_STREAMr   s     rO   -take_response_body_for_interception_as_streamz=NetworkCommands.take_response_body_for_interception_as_stream  s'    0 ?o^ NN
 	
rN   c                    t        | |||      }|||d<   |||d<   |||d<   |||d<   t        t        j                  |      S )aW  
        Emulates custom network conditions for realistic testing scenarios.

        Simulates various network profiles including:
        - Offline mode
        - High-latency connections
        - Bandwidth throttling
        - Unreliable network characteristics

        Args:
            offline: Simulate complete network disconnection
            latency: Minimum latency in milliseconds (round-trip time)
            download_throughput: Max download speed (bytes/sec, -1 to disable)
            upload_throughput: Max upload speed (bytes/sec, -1 to disable)
            connection_type: Network connection type (cellular, wifi, etc.)
            packet_loss: Simulated packet loss percentage (0-100)
            packet_queue_length: Network buffer size simulation
            packet_reordering: Enable packet order randomization

        Typical use cases:
        - Testing progressive loading states
        - Validating offline-first functionality
        - Performance optimization under constrained networks

        Returns:
            Command: CDP command to activate network emulation
        )offlinelatencydownloadThroughputuploadThroughputconnectionType
packetLosspacketQueueLengthpacketReorderingrZ   )r   r   r   EMULATE_NETWORK_CONDITIONS)	r   r   download_throughputupload_throughputconnection_typepacket_losspacket_queue_lengthpacket_reorderingr[   s	            rO   emulate_network_conditionsz*NetworkCommands.emulate_network_conditions9  ss    L 02.	
 &'6F#$"#.F< **=F&'():F%&mFFvVVrN   c                Z    t               }| | |d<   t        t        j                  |      S )a  
        Retrieves security isolation information.

        Provides:
        - CORS status
        - Cross-origin isolation
        - Security context
        - Frame isolation

        Args:
            frame_id: Optional frame to check

        Returns:
            Command: CDP command returning isolation status

        Security aspects:
        - Cross-origin policies
        - Iframe security
        - Site isolation
        - Content protection
        frameIdrZ   )r   r   r   GET_SECURITY_ISOLATION_STATUS)frame_idr[   s     rO   get_security_isolation_statusz-NetworkCommands.get_security_isolation_statuso  s0    2 23 (F9mIIRXYYrN   c                `    t        | |      }|||d<   t        t        j                  |      S )aA  
        Loads a network resource with specific options.

        Features:
        - Custom request configuration
        - Resource loading control
        - Frame-specific loading
        - Error handling

        Args:
            url: Resource URL to load
            options: Loading configuration
            frame_id: Target frame context

        Returns:
            Command: CDP command to load resource

        Usage considerations:
        - Respects CORS policies
        - Handles authentication
        - Manages redirects
        - Supports streaming
        )rV   optionsr   rZ   )r   r   r   LOAD_NETWORK_RESOURCE)rV   r   r   r[   s       rO   load_network_resourcez%NetworkCommands.load_network_resource  s3    : +sGD (F9mAA&QQrN   c                P    t        |       }t        t        j                  |      S )a  
        Replays an XHR request.

        Applications:
        - Request debugging
        - Response testing
        - Race condition analysis
        - API verification

        Args:
            request_id: XHR request to replay

        Returns:
            Command: CDP command to replay XHR

        Note:
        - Maintains original headers
        - Preserves request body
        - Updates timestamps
        - Creates new request ID
        rq   rZ   )r   r   r   
REPLAY_XHRrt   s     rO   
replay_xhrzNetworkCommands.replay_xhr  s!    2 !:6m66vFFrN   )returnr#   )r   r$   )NNNN)rU   strrV   Optional[str]rW   r   rX   r   r]   Optional[CookiePartitionKey]r   r%   )r   r&   )NNN)rg   Optional[int]rh   r   ri   r   r   r(   )N)rl   zOptional[list[str]]r   r+   )ru   r   r   r,   )ru   r   r   r-   )r}   boolr   r8   )NNNNNNNNNNNN)rU   r   r   r   rV   r   rW   r   rX   r   r   Optional[bool]r   r   r   zOptional[CookieSameSite]r   Optional[float]r   zOptional[CookiePriority]r   r   r   zOptional[CookieSourceScheme]r   r   r]   r   r   r9   )r   zlist[SetCookieParams]r   r;   )r   zlist[HeaderEntry]r   r<   )
r   r   r   r   r   r   r   zOptional[UserAgentMetadata]r   r=   )r   r"   )r   r   r   r)   )FF)
ru   r   r   r   r   r   r   r   r   r3   )rl   z	list[str]r   r6   )r   r   r   r7   )r   r   r   r*   )r   r   r   r.   )r   zlist[ContentEncoding]r   r4   )r   r   r   r5   )NN)r   r   r   r   r   r   r   r:   )ru   r   r   r>   )r   r   r   r?   )r   r   r   floatr   r   r   r   r   zOptional[ConnectionType]r   r   r   r   r   r   r   r'   )r   r   r   r/   )rV   r   r   rF   r   r   r   r1   )ru   r   r   r2   )"__name__
__module____qualname____doc__staticmethodrP   rS   r^   ra   rj   ro   rv   ry   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rM   rN   rO   rH   rH   P   s     A A( C C  " $"6:"K"K"K "K 	"K
 4"K 
"K "KH 5 5& /326,0C,C"/C *C 
	C C< $(H!H	H H2 RR	"R R4 NN	N N2 O O*  " $"!%$(.2#'-1%)6:%)6:MGMGMG MG 	MG
 MG MG "MG ,MG !MG +MG #MG 4MG #MG 4MG 
MG MG^ H H0 S"S	#S S4  *."&;?	$T$T&$T  $T 9	$T
 
%$T $TL O O& QQ	"Q Q.   %	!T!T!T !T 	!T
 
%!T !TF M M4 VV	&V V4 L L2 __	._ _4 S(S	$S S4 S S0  ?C@D"P/3"P-;"P 0>"P 
"	"P "PH TT	%T T4 

	7
 
:  59'+-1,03W3W3W #3W !	3W
 23W %3W +3W *3W 
)3W 3Wj "&ZZ	*Z Z:  #'RR+R  R 
$	R RB GG	G GrN   rH   N)K
__future__r   typingr   r   pydoll.protocol.baser   pydoll.protocol.network.methodsr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    pydoll.protocol.emulation.typesr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   pydoll.protocol.network.typesr@   rA   rB   rC   rD   rE   rF   rH   rM   rN   rO   <module>r     s    " * (      : A       @  yG yGrN   