Source: https://h2corn.monicz.dev/api/http/

# HTTP scope and messages

Use these mappings for the HTTP scope and the request and response events exchanged with an ASGI application.

## HTTPScope

Bases: `TypedDict`

An HTTP request scope in [`Scope`](https://h2corn.monicz.dev/api/applications/#h2corn.Scope "Scope module-attribute").

### type`instance-attribute`

```python
type: Literal['http']
```

### asgi`instance-attribute`

```python
asgi: HTTPASGIVersions
```

### http\_version`instance-attribute`

```python
http_version: Literal['1.1', '2']
```

### method`instance-attribute`

```python
method: str
```

### scheme`instance-attribute`

```python
scheme: str
```

### path`instance-attribute`

```python
path: str
```

### raw\_path`instance-attribute`

```python
raw_path: bytes
```

### query\_string`instance-attribute`

```python
query_string: bytes
```

### root\_path`instance-attribute`

```python
root_path: NotRequired[str]
```

### headers`instance-attribute`

```python
headers: ScopeHeaders
```

### client`instance-attribute`

```python
client: NotRequired[tuple[str, int]]
```

### server`instance-attribute`

```python
server: tuple[str, int | None]
```

### state`instance-attribute`

```python
state: NotRequired[State]
```

### extensions`instance-attribute`

```python
extensions: HTTPExtensions
```

## HTTPRequest

Bases: `TypedDict`

An HTTP request event in [`ReceiveMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.ReceiveMessage "ReceiveMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['http.request']
```

### body`instance-attribute`

```python
body: NotRequired[bytes]
```

### more\_body`instance-attribute`

```python
more_body: NotRequired[bool]
```

## HTTPDisconnect

Bases: `TypedDict`

An HTTP disconnect event in [`ReceiveMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.ReceiveMessage "ReceiveMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['http.disconnect']
```

## HTTPResponseStart

Bases: `TypedDict`

An HTTP response-start event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['http.response.start']
```

### status`instance-attribute`

```python
status: int
```

### headers`instance-attribute`

```python
headers: NotRequired[Headers]
```

### trailers`instance-attribute`

```python
trailers: NotRequired[bool]
```

## HTTPResponseBody

Bases: `TypedDict`

An HTTP response-body event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['http.response.body']
```

### body`instance-attribute`

```python
body: NotRequired[bytes]
```

### more\_body`instance-attribute`

```python
more_body: NotRequired[bool]
```

## HTTPResponseTrailers

Bases: `TypedDict`

An HTTP response-trailers event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['http.response.trailers']
```

### headers`instance-attribute`

```python
headers: Headers
```

### more\_trailers`instance-attribute`

```python
more_trailers: NotRequired[bool]
```

## HTTPResponsePathsend

Bases: `TypedDict`

An HTTP path-send event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['http.response.pathsend']
```

### path`instance-attribute`

```python
path: str
```

## HTTPResponseZeroCopySend

Bases: `TypedDict`

A response body segment in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute"), read straight from an open file.

Sent after `http.response.start`, as many times as wanted, and freely interleaved with `http.response.body`. `offset` defaults to the descriptor's current position and `count` to the rest of the file.

The descriptor stays yours: this server duplicates it and closes only the duplicate, so closing it as soon as `send()` returns is safe -- and, per the ASGI specification, your responsibility.

### type`instance-attribute`

```python
type: Literal['http.response.zerocopysend']
```

### file`instance-attribute`

```python
file: SupportsFileno
```

### offset`instance-attribute`

```python
offset: NotRequired[int]
```

### count`instance-attribute`

```python
count: NotRequired[int]
```

### more\_body`instance-attribute`

```python
more_body: NotRequired[bool]
```

## HTTPResponseEarlyHint

Bases: `TypedDict`

An RFC 8297 `103 Early Hints` interim response in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

Sent after `http.response.start` and before the final body, as many times as wanted. Each value becomes one `link` field; ordering and duplicates are preserved. Offered only on HTTP/2 -- check `scope["extensions"]`.

### type`instance-attribute`

```python
type: Literal['http.response.early_hint']
```

### links`instance-attribute`

```python
links: Iterable[bytes]
```
