Skip to content

DownloadResponse

Namespace: Vercel.AI.Util

public sealed class DownloadResponse

One HTTP response seen by Download.

Inheritance: object

View source

DownloadResponse(int, string?, HeaderCollection?, byte[]?, string?)

Section titled “DownloadResponse(int, string?, HeaderCollection?, byte[]?, string?)”
public DownloadResponse(int status, string? statusText, HeaderCollection? headers, byte[]? body, string? type = "basic")

Creates a response.

Parameters

Name Type Description
status int
statusText string
headers HeaderCollection
body byte[]
type string

View source

public byte[]? Body { get; }

Response body. May be null.

Value: byte[]

View source

public bool Cancelled { get; }

Whether Cancel() has run.

Value: bool

View source

public HeaderCollection Headers { get; }

Response headers.

Value: HeaderCollection

View source

public bool Ok { get; }

Whether the status is 200-299.

Value: bool

View source

public Action? OnCancel { get; set; }

Called when the body is cancelled.

Value: Action

View source

public int Status { get; }

HTTP status.

Value: int

View source

public string StatusText { get; }

HTTP status text.

Value: string

View source

public string Type { get; }

basic or opaqueredirect.

Value: string

View source

public static DownloadResponse Bytes(byte[]? body, string? mediaType, int status = 200)

A successful body response.

Parameters

Name Type Description
body byte[]
mediaType string
status int

Returns: DownloadResponse

View source

public void Cancel()

Releases the body. Failures are ignored.

View source

public static DownloadResponse Text(string? text, string? mediaType = "text/plain")

A successful UTF-8 text response.

Parameters

Name Type Description
text string
mediaType string

Returns: DownloadResponse

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product