Tungsten v0.1.0 Tungsten.CDP.Network View Source

Network

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.

Link to this section Summary

Types

Functions

Link to this section Types

Link to this type

cdp_auth_challenge_response_type() View Source
cdp_auth_challenge_response_type() :: %{
  :response => :provide_credentials | :cancel_auth | :default,
  optional(:username) => String.t(),
  optional(:password) => String.t()
}

Network.AuthChallengeResponse

Response to an AuthChallenge.

Link to this type

cdp_auth_challenge_type() View Source
cdp_auth_challenge_type() :: %{
  optional(:source) => :proxy | :server,
  :origin => String.t(),
  :scheme => String.t(),
  :realm => String.t()
}

Network.AuthChallenge

Authorization challenge for HTTP status code 401 or 407.

Link to this type

cdp_blocked_reason_type() View Source
cdp_blocked_reason_type() ::
  :"collapsed-by-client"
  | :"content-type"
  | :"subresource-filter"
  | :inspector
  | :origin
  | :"mixed-content"
  | :csp
  | :other

Network.BlockedReason

The reason why request was blocked.

Link to this type

cdp_cached_resource_type() View Source
cdp_cached_resource_type() :: %{
  :url => String.t(),
  :type => cdp_resource_type_type(),
  optional(:response) => cdp_response_type(),
  :body_size => integer() | float()
}

Network.CachedResource

Information about the cached resource.

Link to this type

cdp_certificate_transparency_compliance_type() View Source
cdp_certificate_transparency_compliance_type() ::
  :compliant | :"not-compliant" | :unknown

Network.CertificateTransparencyCompliance

Whether the request complied with Certificate Transparency policy.

Link to this type

cdp_connection_type_type() View Source
cdp_connection_type_type() ::
  :other
  | :wimax
  | :wifi
  | :ethernet
  | :bluetooth
  | :cellular4g
  | :cellular3g
  | :cellular2g
  | :none

Network.ConnectionType

The underlying connection technology that the browser is supposedly using.

Link to this type

cdp_error_reason_type() View Source
cdp_error_reason_type() ::
  :blocked_by_response
  | :blocked_by_client
  | :address_unreachable
  | :internet_disconnected
  | :name_not_resolved
  | :connection_failed
  | :connection_aborted
  | :connection_refused
  | :connection_reset
  | :connection_closed
  | :access_denied
  | :timed_out
  | :aborted
  | :failed

Network.ErrorReason

Network level fetch failure reason.

Link to this type

cdp_headers_type() View Source
cdp_headers_type() :: map()

Network.Headers

Request / response headers as keys / values of JSON object.

Link to this type

cdp_initiator_type() View Source
cdp_initiator_type() :: %{
  :type => :other | :signed_exchange | :preload | :script | :parser,
  optional(:stack) => Tungsten.CDP.Runtime.cdp_stack_trace_type(),
  optional(:url) => String.t(),
  optional(:line_number) => integer() | float()
}

Network.Initiator

Information about the request initiator.

Link to this type

cdp_interception_id_type() View Source
cdp_interception_id_type() :: String.t()

Network.InterceptionId

Unique intercepted request identifier.

Link to this type

cdp_interception_stage_type() View Source
cdp_interception_stage_type() :: :headers_received | :request

Network.InterceptionStage

Stages of the interception to begin intercepting. Request will intercept before the request is sent. Response will intercept after the response is received.

Link to this type

cdp_loader_id_type() View Source
cdp_loader_id_type() :: String.t()

Network.LoaderId

Unique loader identifier.

Link to this type

cdp_monotonic_time_type() View Source
cdp_monotonic_time_type() :: integer() | float()

Network.MonotonicTime

Monotonically increasing time in seconds since an arbitrary point in the past.

Link to this type

cdp_request_id_type() View Source
cdp_request_id_type() :: String.t()

Network.RequestId

Unique request identifier.

Link to this type

cdp_request_pattern_type() View Source
cdp_request_pattern_type() :: %{
  optional(:url_pattern) => String.t(),
  optional(:resource_type) => cdp_resource_type_type(),
  optional(:interception_stage) => cdp_interception_stage_type()
}

Network.RequestPattern

Request pattern for interception.

Link to this type

cdp_request_type() View Source
cdp_request_type() :: %{
  :url => String.t(),
  optional(:url_fragment) => String.t(),
  :method => String.t(),
  :headers => cdp_headers_type(),
  optional(:post_data) => String.t(),
  optional(:has_post_data) => boolean(),
  optional(:mixed_content_type) =>
    Tungsten.CDP.Security.cdp_mixed_content_type_type(),
  :initial_priority => cdp_resource_priority_type(),
  :referrer_policy =>
    :"strict-origin-when-cross-origin"
    | :"strict-origin"
    | :"same-origin"
    | :"origin-when-cross-origin"
    | :origin
    | :"no-referrer"
    | :"no-referrer-when-downgrade"
    | :"unsafe-url",
  optional(:is_link_preload) => boolean()
}

Network.Request

HTTP request data.

Link to this type

cdp_resource_priority_type() View Source
cdp_resource_priority_type() :: :very_high | :high | :medium | :low | :very_low

Network.ResourcePriority

Loading priority of a resource request.

Link to this type

cdp_resource_timing_type() View Source
cdp_resource_timing_type() :: %{
  request_time: integer() | float(),
  proxy_start: integer() | float(),
  proxy_end: integer() | float(),
  dns_start: integer() | float(),
  dns_end: integer() | float(),
  connect_start: integer() | float(),
  connect_end: integer() | float(),
  ssl_start: integer() | float(),
  ssl_end: integer() | float(),
  worker_start: integer() | float(),
  worker_ready: integer() | float(),
  send_start: integer() | float(),
  send_end: integer() | float(),
  push_start: integer() | float(),
  push_end: integer() | float(),
  receive_headers_end: integer() | float()
}

Network.ResourceTiming

Timing information for the request.

Link to this type

cdp_resource_type_type() View Source
cdp_resource_type_type() ::
  :other
  | :csp_violation_report
  | :ping
  | :signed_exchange
  | :manifest
  | :web_socket
  | :event_source
  | :fetch
  | :xhr
  | :text_track
  | :script
  | :font
  | :media
  | :image
  | :stylesheet
  | :document

Network.ResourceType

Resource type as it was perceived by the rendering engine.

Link to this type

cdp_response_type() View Source
cdp_response_type() :: %{
  :url => String.t(),
  :status => integer(),
  :status_text => String.t(),
  :headers => cdp_headers_type(),
  optional(:headers_text) => String.t(),
  :mime_type => String.t(),
  optional(:request_headers) => cdp_headers_type(),
  optional(:request_headers_text) => String.t(),
  :connection_reused => boolean(),
  :connection_id => integer() | float(),
  optional(:remote_ip_address) => String.t(),
  optional(:remote_port) => integer(),
  optional(:from_disk_cache) => boolean(),
  optional(:from_service_worker) => boolean(),
  :encoded_data_length => integer() | float(),
  optional(:timing) => cdp_resource_timing_type(),
  optional(:protocol) => String.t(),
  :security_state => Tungsten.CDP.Security.cdp_security_state_type(),
  optional(:security_details) => cdp_security_details_type()
}

Network.Response

HTTP response data.

Link to this type

cdp_security_details_type() View Source
cdp_security_details_type() :: %{
  :protocol => String.t(),
  :key_exchange => String.t(),
  optional(:key_exchange_group) => String.t(),
  :cipher => String.t(),
  optional(:mac) => String.t(),
  :certificate_id => Tungsten.CDP.Security.cdp_certificate_id_type(),
  :subject_name => String.t(),
  :san_list => [String.t()],
  :issuer => String.t(),
  :valid_from => cdp_time_since_epoch_type(),
  :valid_to => cdp_time_since_epoch_type(),
  :signed_certificate_timestamp_list => [
    cdp_signed_certificate_timestamp_type()
  ],
  :certificate_transparency_compliance =>
    cdp_certificate_transparency_compliance_type()
}

Network.SecurityDetails

Security details about a request.

Link to this type

cdp_signed_certificate_timestamp_type() View Source
cdp_signed_certificate_timestamp_type() :: %{
  status: String.t(),
  origin: String.t(),
  log_description: String.t(),
  log_id: String.t(),
  timestamp: cdp_time_since_epoch_type(),
  hash_algorithm: String.t(),
  signature_algorithm: String.t(),
  signature_data: String.t()
}

Network.SignedCertificateTimestamp

Details of a signed certificate timestamp (SCT).

Link to this type

cdp_signed_exchange_error_field_type() View Source
cdp_signed_exchange_error_field_type() ::
  :signature_timestamps
  | :signature_validity_url
  | :signature_cert_sha256
  | :signature_cert_url
  | :signature_integrity
  | :signature_sig

Network.SignedExchangeErrorField

Field type for a signed exchange related error.

Link to this type

cdp_signed_exchange_error_type() View Source
cdp_signed_exchange_error_type() :: %{
  :message => String.t(),
  optional(:signature_index) => integer(),
  optional(:error_field) => cdp_signed_exchange_error_field_type()
}

Network.SignedExchangeError

Information about a signed exchange response.

Link to this type

cdp_signed_exchange_header_type() View Source
cdp_signed_exchange_header_type() :: %{
  request_url: String.t(),
  response_code: integer(),
  response_headers: cdp_headers_type(),
  signatures: [cdp_signed_exchange_signature_type()]
}

Network.SignedExchangeHeader

Information about a signed exchange header. https://wicg.github.io/webpackage/draft-yasskin-httpbis-origin-signed-exchanges-impl.html#cbor-representation

Link to this type

cdp_signed_exchange_info_type() View Source
cdp_signed_exchange_info_type() :: %{
  :outer_response => cdp_response_type(),
  optional(:header) => cdp_signed_exchange_header_type(),
  optional(:security_details) => cdp_security_details_type(),
  optional(:errors) => [cdp_signed_exchange_error_type()]
}

Network.SignedExchangeInfo

Information about a signed exchange response.

Link to this type

cdp_signed_exchange_signature_type() View Source
cdp_signed_exchange_signature_type() :: %{
  :label => String.t(),
  :signature => String.t(),
  :integrity => String.t(),
  optional(:cert_url) => String.t(),
  optional(:cert_sha256) => String.t(),
  :validity_url => String.t(),
  :date => integer(),
  :expires => integer(),
  optional(:certificates) => [String.t()]
}

Network.SignedExchangeSignature

Information about a signed exchange signature. https://wicg.github.io/webpackage/draft-yasskin-httpbis-origin-signed-exchanges-impl.html#rfc.section.3.1

Link to this type

cdp_time_since_epoch_type() View Source
cdp_time_since_epoch_type() :: integer() | float()

Network.TimeSinceEpoch

UTC time in seconds, counted from January 1, 1970.

Link to this type

cdp_web_socket_frame_type() View Source
cdp_web_socket_frame_type() :: %{
  opcode: integer() | float(),
  mask: boolean(),
  payload_data: String.t()
}

Network.WebSocketFrame

WebSocket message data. This represents an entire WebSocket message, not just a fragmented frame as the name suggests.

Link to this type

cdp_web_socket_request_type() View Source
cdp_web_socket_request_type() :: %{headers: cdp_headers_type()}

Network.WebSocketRequest

WebSocket request data.

Link to this type

cdp_web_socket_response_type() View Source
cdp_web_socket_response_type() :: %{
  :status => integer(),
  :status_text => String.t(),
  :headers => cdp_headers_type(),
  optional(:headers_text) => String.t(),
  optional(:request_headers) => cdp_headers_type(),
  optional(:request_headers_text) => String.t()
}

Network.WebSocketResponse

WebSocket response data.

Link to this section Functions

Link to this function

can_clear_browser_cache(session, parameters \\ %{}, options \\ []) View Source
can_clear_browser_cache(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{result: boolean()}} | {:error, term()}

Network.canClearBrowserCache

Tells whether clearing browser cache is supported.

Link to this function

can_clear_browser_cookies(session, parameters \\ %{}, options \\ []) View Source
can_clear_browser_cookies(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{result: boolean()}} | {:error, term()}

Network.canClearBrowserCookies

Tells whether clearing browser cookies is supported.

Link to this function

can_emulate_network_conditions(session, parameters \\ %{}, options \\ []) View Source
can_emulate_network_conditions(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, %{result: boolean()}} | {:error, term()}

Network.canEmulateNetworkConditions

Tells whether emulation of network conditions is supported.

Link to this function

clear_browser_cache(session, parameters \\ %{}, options \\ []) View Source
clear_browser_cache(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.clearBrowserCache

Clears browser cache.

Link to this function

clear_browser_cookies(session, parameters \\ %{}, options \\ []) View Source
clear_browser_cookies(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.clearBrowserCookies

Clears browser cookies.

Link to this function

continue_intercepted_request(session, parameters, options \\ []) View Source
continue_intercepted_request(
  GenServer.server(),
  %{
    :interception_id => cdp_interception_id_type(),
    optional(:error_reason) => cdp_error_reason_type(),
    optional(:raw_response) => String.t(),
    optional(:url) => String.t(),
    optional(:method) => String.t(),
    optional(:post_data) => String.t(),
    optional(:headers) => cdp_headers_type(),
    optional(:auth_challenge_response) => cdp_auth_challenge_response_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.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.

Link to this function

delete_cookies(session, parameters, options \\ []) View Source
delete_cookies(
  GenServer.server(),
  %{
    :name => String.t(),
    optional(:url) => String.t(),
    optional(:domain) => String.t(),
    optional(:path) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.deleteCookies

Deletes browser cookies with matching name and url or domain/path pair.

Link to this function

disable(session, parameters \\ %{}, options \\ []) View Source
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Network.disable

Disables network tracking, prevents network events from being sent to the client.

Link to this function

emulate_network_conditions(session, parameters, options \\ []) View Source
emulate_network_conditions(
  GenServer.server(),
  %{
    :offline => boolean(),
    :latency => integer() | float(),
    :download_throughput => integer() | float(),
    :upload_throughput => integer() | float(),
    optional(:connection_type) => cdp_connection_type_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.emulateNetworkConditions

Activates emulation of network conditions.

Link to this function

enable(session, parameters \\ %{}, options \\ []) View Source
enable(
  GenServer.server(),
  %{
    optional(:max_total_buffer_size) => integer(),
    optional(:max_resource_buffer_size) => integer(),
    optional(:max_post_data_size) => integer()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.enable

Enables network tracking, network events will now be delivered to the client.

Link to this function

get_all_cookies(session, parameters \\ %{}, options \\ []) View Source
get_all_cookies(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, %{cookies: [cdp_cookie_type()]}} | {:error, term()}

Network.getAllCookies

Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.

Link to this function

get_certificate(session, parameters, options \\ []) View Source
get_certificate(
  GenServer.server(),
  %{origin: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{table_names: [String.t()]}} | {:error, term()}

Network.getCertificate

Returns the DER-encoded certificate.

Link to this function

get_cookies(session, parameters \\ %{}, options \\ []) View Source
get_cookies(
  GenServer.server(),
  %{optional(:urls) => [String.t()]},
  Tungsten.Connection.exec_options()
) :: {:ok, %{cookies: [cdp_cookie_type()]}} | {:error, term()}

Network.getCookies

Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.

Link to this function

get_request_post_data(session, parameters, options \\ []) View Source
get_request_post_data(
  GenServer.server(),
  %{request_id: cdp_request_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{post_data: String.t()}} | {:error, term()}

Network.getRequestPostData

Returns post data sent with the request. Returns an error when no data was sent with the request.

Link to this function

get_response_body(session, parameters, options \\ []) View Source
get_response_body(
  GenServer.server(),
  %{request_id: cdp_request_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{body: String.t(), base64_encoded: boolean()}} | {:error, term()}

Network.getResponseBody

Returns content served for the given request.

Link to this function

get_response_body_for_interception(session, parameters, options \\ []) View Source
get_response_body_for_interception(
  GenServer.server(),
  %{interception_id: cdp_interception_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{body: String.t(), base64_encoded: boolean()}} | {:error, term()}

Network.getResponseBodyForInterception

Returns content served for the given currently intercepted request.

Link to this function

replay_xhr(session, parameters, options \\ []) View Source
replay_xhr(
  GenServer.server(),
  %{request_id: cdp_request_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.replayXHR

This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password.

Link to this function

search_in_response_body(session, parameters, options \\ []) View Source
search_in_response_body(
  GenServer.server(),
  %{
    :request_id => cdp_request_id_type(),
    :query => String.t(),
    optional(:case_sensitive) => boolean(),
    optional(:is_regex) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{result: [Tungsten.CDP.Debugger.cdp_search_match_type()]}}
  | {:error, term()}

Network.searchInResponseBody

Searches for given string in response content.

Link to this function

set_blocked_ur_ls(session, parameters, options \\ []) View Source
set_blocked_ur_ls(
  GenServer.server(),
  %{urls: [String.t()]},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setBlockedURLs

Blocks URLs from loading.

Link to this function

set_bypass_service_worker(session, parameters, options \\ []) View Source
set_bypass_service_worker(
  GenServer.server(),
  %{bypass: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setBypassServiceWorker

Toggles ignoring of service worker for each request.

Link to this function

set_cache_disabled(session, parameters, options \\ []) View Source
set_cache_disabled(
  GenServer.server(),
  %{cache_disabled: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setCacheDisabled

Toggles ignoring cache for each request. If true, cache will not be used.

Link to this function

set_cookie(session, parameters, options \\ []) View Source
set_cookie(
  GenServer.server(),
  %{
    :name => String.t(),
    :value => String.t(),
    optional(:url) => String.t(),
    optional(:domain) => String.t(),
    optional(:path) => String.t(),
    optional(:secure) => boolean(),
    optional(:http_only) => boolean(),
    optional(:same_site) => cdp_cookie_same_site_type(),
    optional(:expires) => cdp_time_since_epoch_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{success: boolean()}} | {:error, term()}

Network.setCookie

Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.

Link to this function

set_cookies(session, parameters, options \\ []) View Source
set_cookies(
  GenServer.server(),
  %{cookies: [cdp_cookie_param_type()]},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setCookies

Sets given cookies.

Link to this function

set_data_size_limits_for_test(session, parameters, options \\ []) View Source
set_data_size_limits_for_test(
  GenServer.server(),
  %{max_total_size: integer(), max_resource_size: integer()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setDataSizeLimitsForTest

For testing.

Link to this function

set_extra_http_headers(session, parameters, options \\ []) View Source
set_extra_http_headers(
  GenServer.server(),
  %{headers: cdp_headers_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setExtraHTTPHeaders

Specifies whether to always send extra HTTP headers with the requests from this page.

Link to this function

set_request_interception(session, parameters, options \\ []) View Source
set_request_interception(
  GenServer.server(),
  %{patterns: [cdp_request_pattern_type()]},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setRequestInterception

Sets the requests to intercept that match the provided patterns and optionally resource types.

Link to this function

set_user_agent_override(session, parameters, options \\ []) View Source
set_user_agent_override(
  GenServer.server(),
  %{
    :user_agent => String.t(),
    optional(:accept_language) => String.t(),
    optional(:platform) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Network.setUserAgentOverride

Allows overriding user agent with the given string.

Link to this function

take_response_body_for_interception_as_stream(session, parameters, options \\ []) View Source
take_response_body_for_interception_as_stream(
  GenServer.server(),
  %{interception_id: cdp_interception_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{stream: Tungsten.CDP.IO.cdp_stream_handle_type()}} | {:error, term()}

Network.takeResponseBodyForInterceptionAsStream

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.