# `CDPEx.Proxy`
[🔗](https://github.com/patrols/cdp_ex/blob/v0.9.0/lib/cdp_ex/proxy.ex#L1)

Parses the `:proxy` launch option into a Chrome `--proxy-server` flag plus, when the
proxy is authenticated, the credentials `CDPEx.Browser` arms on each page.

Accepts either a URL string or a keyword list / map:

    "http://user:pass@host:8080"
    [server: "host:8080", scheme: "http", username: "user", password: "pass"]

In the URL form, credentials with reserved characters must be percent-encoded
(e.g. `p@ss` → `p%40ss`); they are decoded back on parse. The keyword form takes
credentials verbatim, so prefer it when a password contains reserved characters.

See the `:proxy` option on `CDPEx.launch/1`.

# `t`

```elixir
@type t() :: %{
  server: String.t(),
  username: String.t() | nil,
  password: String.t() | nil
}
```

A parsed proxy: the `scheme://host:port` value for Chrome's `--proxy-server`
(userinfo stripped), plus optional credentials (`nil` for an open proxy).

# `credentials`

```elixir
@spec credentials(t()) :: %{username: String.t(), password: String.t()} | nil
```

Credentials (`%{username, password}`) when the proxy needs auth, else `nil`.

Both parts must be present and non-empty; a missing or empty half is treated as no
auth (the proxy is used unauthenticated).

# `parse`

```elixir
@spec parse(term()) :: {:ok, t()} | {:error, {:invalid_proxy, term()}}
```

Parses a `:proxy` value into `{:ok, t}` or `{:error, {:invalid_proxy, reason}}`.

# `to_arg`

```elixir
@spec to_arg(t()) :: String.t()
```

The `--proxy-server=…` Chrome flag for a parsed proxy.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
