# Files and Streams

> UCall for C

A streamed reply is chunked for HTTP/1.1 peers, keeps identity framing when its headers declare `Content-Length`, and is delimited by the close for HTTP/1.0 peers; a chunk reports `ucall_status_would_block_k` while the socket lags too far behind.
Vectored replies and stream chunks take reply parts: bytes, a range of a file descriptor the caller keeps open until the outcome is final, or a range of a path opened beneath one of the interface's `reply_directories`.
The event loop opens files with `O_DIRECT`, refusing caller descriptors without it, and reads aligned extents itself before sending the requested slice.
Replies leave through zero-copy sends, so a connection closes only once the kernel let go of what it sent, and resets a peer that stops acknowledging by the linger deadline.
A reply with file or path parts publishes its outcome as `ucall_status_deferred_k`, then success once they are sent, or the cause; a refusal before the head becomes `404` or `416`, and a failure after it resets the connection.

`#include <ucall/server.h>`

## ucall_file_range_t

A byte range of a file the caller opened.

```c
struct ucall_file_range_t
```

UCall never closes the descriptor: the caller keeps it open until the reply's outcome leaves [`ucall_status_deferred_k`](https://www.unum.cloud/docs/ucall/c/errors.md#ucall_status_deferred_k), and may close it right after any synchronous refusal.

- `file_descriptor` `int`: A regular file opened with `O_DIRECT`, borrowed; a descriptor without it is refused with [`ucall_status_invalid_argument_k`](https://www.unum.cloud/docs/ucall/c/errors.md#ucall_status_invalid_argument_k).
- `offset` `uint64_t`: The range's first byte.
- `length` `uint64_t`: The range's byte count; zero sends through the end of the file.

## ucall_path_range_t

A byte range of a file UCall opens unbuffered beneath a registered directory, and closes once the part is sent or dropped.

```c
struct ucall_path_range_t
```

Empty, absolute paths, `".."` components and NUL bytes are refused, and so is any resolution leaving the directory, symbolic links included.

- `directory_index` `size_t`: A position below the `reply_directories_count` of the interface the request arrived on.
- `relative_path` `ucall_bytes_view_t`: The file beneath that directory, copied before the call returns.
- `offset` `uint64_t`: The range's first byte.
- `length` `uint64_t`: The range's byte count; zero sends through the end of the file.

