crater-network

    WebDriver BiDi synthetic network state and byte/query encoding helpers for crater adapters

    Download zip
    Author
    Version
    0.19.2
    License
    Apache-2.0
    Last updated
    7 days ago
    Downloads
    5K

    No dependencies

    #Crater Network

    WebDriver BiDi synthetic network state and byte/query encoding helpers shared by Crater adapters.

    This module is not a general HTTP client boundary. Browser HTTP policy stays in mizchi/crater-browser-http; WebDriver BiDi command dispatch and browser integration stay in mizchi/crater-webdriver-bidi.

    BidiNetworkState

    pub(all) struct BidiNetworkState {
    network_intercepts : Map[String,
    Json
    ]
    next_network_intercept_id : Int
    next_network_request_id : Int
    network_cache_behavior_global : String
    network_extra_headers_global : Map[String, String]
    network_extra_headers_by_context : Map[String, Map[String, String]]
    network_extra_headers_by_user_context : Map[String, Map[String, String]]
    network_cache_behavior_by_context : Map[String, String]
    network_state_channel_by_context : Map[String, String]
    network_cached_requests_by_context : Map[String, Map[String, Bool]]
    network_blocked_requests : Map[String,
    Json
    ]
    network_data_collectors : Map[String,
    Json
    ]
    network_collected_data : Map[String, Map[String, Map[String,
    Json
    ]]]
    next_network_data_collector_id : Int
    }

    WebDriver BiDi network runtime state.

    BidiNetworkState::new

    CanonicalNetworkHttpUrl

    pub(all) struct CanonicalNetworkHttpUrl {
    scheme : String
    host : String
    port : Int
    path : String
    query : String
    }

    SyntheticFetchCommandResult

    pub(all) struct SyntheticFetchCommandResult {
    blocked_text : String?
    response_value :
    Json

    }

    SyntheticFetchPlanEntry

    pub(all) struct SyntheticFetchPlanEntry {
    url : String
    http_method : String
    request_token : String
    redirect_count : Int
    request_value :
    Json
    ?
    }

    SyntheticFetchStepResult

    pub(all) struct SyntheticFetchStepResult {
    blocked_text : String?
    response_value :
    Json
    ?
    }

    SyntheticNetworkContinueCredentials

    pub(all) struct SyntheticNetworkContinueCredentials {
    username : String
    password : String
    }

    SyntheticNetworkCookie

    pub(all) struct SyntheticNetworkCookie {
    name : String
    value_text : String
    domain : String
    domain_explicit : Bool
    path : String
    http_only : Bool
    secure : Bool
    same_site : String
    expiry : Int?
    }

    SyntheticNetworkCookieOverride

    pub(all) struct SyntheticNetworkCookieOverride {
    enabled : Bool
    cookies : Array[
    Json
    ]
    }

    SyntheticNetworkEventInput

    pub(all) struct SyntheticNetworkEventInput {
    context_id : String
    url : String
    http_method : String
    request_token : String
    request_headers : Array[
    Json
    ]
    request_value :
    Json
    ?
    request_cookies : Array[
    Json
    ]
    request_cookies_override : Bool
    intercepts : Array[String]
    redirect_count : Int
    navigation : String?
    destination : String
    initiator_type : String?
    }

    SyntheticNetworkResponseOverrides

    pub(all) struct SyntheticNetworkResponseOverrides {
    from_cache : Bool
    headers : Array[
    Json
    ]
    mime_type : String
    protocol : String
    status : Int
    status_text : String
    auth_challenges :
    Json
    ?
    }

    SyntheticNetworkSetCookieOverrideEntry

    pub(all) struct SyntheticNetworkSetCookieOverrideEntry {
    set_cookie_header_value : String
    cookie : SyntheticNetworkCookie
    }

    base64_byte_length

    fn base64_byte_length(value : String) -> Int

    canonicalize_network_http_url

    fn canonicalize_network_http_url(url : String) -> CanonicalNetworkHttpUrl?

    decode_query_component

    fn decode_query_component(value : String) -> String

    extract_network_url_query

    fn extract_network_url_query(url : String) -> String

    network_intercept_matches_phase

    fn network_intercept_matches_phase(options : Map[String,
    Json
    ], phase : String) -> Bool

    network_option_contexts_match

    fn network_option_contexts_match(options : Map[String,
    Json
    ], ancestry : Array[String]) -> Bool

    network_url_patterns_match

    fn network_url_patterns_match(options : Map[String,
    Json
    ], url : String) -> Bool

    synthetic_network_cache_key

    fn synthetic_network_cache_key(http_method : String, url : String) -> String

    synthetic_network_credentials_match_expected

    fn synthetic_network_credentials_match_expected(url : String, credentials : SyntheticNetworkContinueCredentials?) -> Bool

    synthetic_network_decode_base64

    fn synthetic_network_decode_base64(base64 : String) -> String

    synthetic_network_expected_auth_credentials

    fn synthetic_network_expected_auth_credentials(url : String) -> SyntheticNetworkContinueCredentials?

    fn synthetic_network_extract_set_cookie_entries(headers : Array[
    Json
    ], base_url : String, now_seconds : Int) -> Array[SyntheticNetworkCookie]

    synthetic_network_first_query_value

    fn synthetic_network_first_query_value(url : String, key : String) -> String?

    fn synthetic_network_format_set_cookie_header(entry : Map[String,
    Json
    ]) -> String

    synthetic_network_header_entries_from_object

    fn synthetic_network_header_entries_from_object(raw_headers : Map[String,
    Json
    ]) -> Array[
    Json
    ]

    synthetic_network_header_entry_name

    fn synthetic_network_header_entry_name(header :
    Json
    ) -> String?

    synthetic_network_header_entry_string_value

    fn synthetic_network_header_entry_string_value(header :
    Json
    ) -> String?

    synthetic_network_header_string_entry

    fn synthetic_network_header_string_entry(name : String, value : String) ->
    Json

    synthetic_network_infer_mime_type

    fn synthetic_network_infer_mime_type(url : String, path : String) -> String

    synthetic_network_int_query_param

    fn synthetic_network_int_query_param(url : String, key : String, default_value : Int) -> Int

    synthetic_network_is_valid_continue_url

    fn synthetic_network_is_valid_continue_url(url : String) -> Bool

    synthetic_network_is_valid_header_name_token

    fn synthetic_network_is_valid_header_name_token(name : String) -> Bool

    synthetic_network_is_valid_header_string_value

    fn synthetic_network_is_valid_header_string_value(value : String) -> Bool

    synthetic_network_merge_header_entries

    fn synthetic_network_merge_header_entries(headers : Array[
    Json
    ]) -> Array[
    Json
    ]

    synthetic_network_normalize_bytes_value

    fn synthetic_network_normalize_bytes_value(raw_value :
    Json
    , field_name : String) -> Result[
    Json
    , String]

    synthetic_network_normalize_continue_credentials

    fn synthetic_network_normalize_continue_credentials(raw_credentials :
    Json
    ) -> Result[SyntheticNetworkContinueCredentials, String]

    synthetic_network_normalize_continue_url

    fn synthetic_network_normalize_continue_url(raw_url :
    Json
    ) -> Result[String, String]

    synthetic_network_normalize_header_entries

    fn synthetic_network_normalize_header_entries(raw_headers :
    Json
    ?, field_name : String) -> Result[Array[
    Json
    ], String]

    fn synthetic_network_normalize_request_cookie_entries(raw_cookies :
    Json
    ?) -> Result[SyntheticNetworkCookieOverride, String]

    synthetic_network_normalize_response_overrides

    fn synthetic_network_normalize_response_overrides(raw_overrides :
    Json
    ?) -> Result[SyntheticNetworkResponseOverrides, String]

    synthetic_network_normalize_set_cookie_override_entry

    fn synthetic_network_normalize_set_cookie_override_entry(entry : Map[String,
    Json
    ], name : String, value_text : String, base_url : String, now_seconds : Int) -> Result[SyntheticNetworkSetCookieOverrideEntry, String]

    synthetic_network_normalize_string_list

    fn synthetic_network_normalize_string_list(raw_list :
    Json
    ?, field_name : String) -> Result[Array[String], String]

    fn synthetic_network_parse_document_cookie_assignment(cookie_assignment : String, base_url : String, default_path : String, now_seconds : Int) -> SyntheticNetworkCookie?

    fn synthetic_network_parse_set_cookie_header_value(header_value : String, base_url : String, now_seconds : Int) -> SyntheticNetworkCookie?

    synthetic_network_query_values

    fn synthetic_network_query_values(url : String, key : String) -> Array[String]

    synthetic_network_request_body_size

    fn synthetic_network_request_body_size(raw_value :
    Json
    ?, field_name : String) -> Result[Int, String]

    synthetic_network_request_header_string_value

    fn synthetic_network_request_header_string_value(headers : Array[
    Json
    ], name : String) -> String?

    synthetic_network_request_path

    fn synthetic_network_request_path(url : String) -> String

    synthetic_network_response_overrides_to_json

    fn synthetic_network_response_overrides_to_json(overrides : SyntheticNetworkResponseOverrides) ->
    Json

    synthetic_network_status_text_for_code

    fn synthetic_network_status_text_for_code(status : Int) -> String

    synthetic_network_string_from_bytes_value

    fn synthetic_network_string_from_bytes_value(raw_value :
    Json
    , field_name : String) -> Result[String, String]

    synthetic_network_text_from_bytes_value

    fn synthetic_network_text_from_bytes_value(raw_value :
    Json
    , field_name : String) -> Result[String, String]

    synthetic_network_validate_header_entry

    fn synthetic_network_validate_header_entry(entry :
    Json
    ) ->
    Json
    ?

    synthetic_network_validate_header_value

    fn synthetic_network_validate_header_value(value :
    Json
    ) ->
    Json
    ?

    utf8_byte_length

    fn utf8_byte_length(value : String) -> Int