C · Files and Streams

Files and Streams

#include <ucall/server.h> 1.0.0-rc.1 · 60202332

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.

API

Types

ucall_file_range_tA byte range of a file the caller opened.
server.h:1183 ↗
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, and may close it right after any synchronous refusal.

Fields

file_descriptorintA regular file opened with O_DIRECT, borrowed; a descriptor without it is refused with ucall_status_invalid_argument_k.
offsetuint64_tThe range's first byte.
lengthuint64_tThe range's byte count; zero sends through the end of the file.
ucall_path_range_tA byte range of a file UCall opens unbuffered beneath a registered directory, and closes once the part is sent or dropped.
server.h:1200 ↗
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.

Fields

directory_indexsize_tA position below the reply_directories_count of the interface the request arrived on.
relative_pathucall_bytes_view_tThe file beneath that directory, copied before the call returns.
offsetuint64_tThe range's first byte.
lengthuint64_tThe range's byte count; zero sends through the end of the file.