ContentResponse class

Namespace Runic.Desktop · Runic.Desktop 0.7.0-preview.5

public sealed class ContentResponse

Represents an empty, fixed, or streaming content response.

Constructors

ContentResponse

public ContentResponse(ReadOnlyMemory<byte> body, string? contentType = null, int statusCode = 200, IReadOnlyDictionary<string, string>? headers = null)

Creates a fixed response.

Properties

Body

public ReadOnlyMemory<byte> Body { get; }

Gets the fixed body, or empty memory for a streaming response.

ContentLength

public long? ContentLength { get; }

Gets the body length when known before streaming.

ContentType

public string? ContentType { get; }

Gets the response content type.

Headers

public IReadOnlyDictionary<string, string>? Headers { get; }

Gets additional response headers.

IsStreaming

public bool IsStreaming { get; }

Gets whether this response opens a request-scoped stream.

StatusCode

public int StatusCode { get; }

Gets the HTTP status code.

Methods

Stream

public static ContentResponse Stream(ContentStreamFactory streamFactory, string? contentType = null, int statusCode = 200, long? contentLength = null, IReadOnlyDictionary<string, string>? headers = null)

Creates a response whose stream is opened once per GET request.

Text

public static ContentResponse Text(string text, string contentType = "text/html; charset=utf-8", int statusCode = 200)

Creates a UTF-8 text response.