# `ExMCP.HttpPlug.SSEConnection`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.4.0/lib/ex_mcp/http_plug/sse_connection.ex#L1)

Connection operations `ExMCP.HttpPlug.SSEHandler` needs from its socket.

The handler used to sniff its `conn` at runtime (`is_struct/1` plus
`Map.has_key?/2` checks for `:chunk` and `:get_req_header` function fields)
so that tests could pass a fake connection. That put test-only branches in
the production write path.

Instead the handler calls a *connection module* resolved once at start-up
from the `:conn_module` key of its options, defaulting to
`ExMCP.HttpPlug.SSEConnection.PlugConn`. Tests (or alternative adapters)
supply their own implementation:

    SSEHandler.start_link(fake_conn, session_id, %{conn_module: MyFakeConn})

# `conn`

```elixir
@type conn() :: term()
```

# `chunk`

```elixir
@callback chunk(conn(), iodata()) :: {:ok, conn()} | {:error, term()}
```

Writes a chunk to the connection.

# `get_req_header`

```elixir
@callback get_req_header(conn(), String.t()) :: [String.t()]
```

Reads a request header, returning a (possibly empty) list of values.

# `resolve`

```elixir
@spec resolve(map() | keyword()) :: module()
```

Resolves the connection module from handler options.

---

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