HTTP API Toolkit HTTP API Toolkit
HTTP API Toolkit HTTP API Toolkit
DocFX + Singulink = ♥

Search Results for

    Class StreamingResponse

    Defines the streaming response format used for endpoints that return IAsyncEnumerable<T> results and provides methods for reading it.

    Inheritance
    object
    StreamingResponse
    Namespace: Singulink.Net.Http.Api
    Assembly: Singulink.Net.Http.Api.dll
    Syntax
    public static class StreamingResponse
    Remarks

    A streaming response is a application/jsonl body containing one JSON record per line. Each record is an object with exactly one of the following properties:

    • "item": an item produced by the endpoint (which may be null), serialized using the service's JSON options for the endpoint's declared item type.
    • "ping": true. A keep-alive record sent while the endpoint is waiting for its next item. Ignored by readers.
    • "error": an object with "status", optional "code" and "message" properties describing an exception thrown during enumeration. This terminates the stream.
    • "end": true. Marks successful completion of the stream.

    Every successful stream ends with an "end" record, so a stream that ends without an "end" or "error" record was truncated. Exceptions thrown before any record has been written are reported as a regular (non-streaming) error response instead.

    Fields

    Name Description
    ContentType

    The full content type of streaming responses, including the character set.

    MediaType

    The media type of streaming responses (application/jsonl).

    Methods

    Name Description
    ReadItemsAsync<TItem>(Stream, JsonSerializerOptions, CancellationToken)

    Reads the items from a streaming response body using the specified serializer options to deserialize items.

    ReadItemsAsync<TItem>(Stream, JsonTypeInfo<TItem>, CancellationToken)

    Reads the items from a streaming response body. Ping records are skipped, error records are thrown as the corresponding ApiException, and the enumeration completes when the end record is received. Null items are yielded as null, so a nullable item type should be used if the endpoint can produce them.

    © Singulink. All rights reserved.