ResponseBodies
Namespace: Vercel.AI.ProviderUtils
public static class ResponseBodiesReads and releases HTTP response bodies.
Inheritance: object
Methods
Section titled “Methods”CancelResponseBody(HttpResponseMessage)
Section titled “CancelResponseBody(HttpResponseMessage)”public static void CancelResponseBody(HttpResponseMessage response)Releases the response body so the connection can be reused. Errors are swallowed so they do not hide the original failure.
Maps to cancelResponseBody.
Parameters
| Name | Type | Description |
|---|---|---|
response |
HttpResponseMessage |
ReadResponseWithSizeLimitAsync(HttpResponseMessage, string, long?, CancellationToken)
Section titled “ReadResponseWithSizeLimitAsync(HttpResponseMessage, string, long?, CancellationToken)”public static Task<byte[]> ReadResponseWithSizeLimitAsync(HttpResponseMessage response, string url, long? maxBytes = null, CancellationToken cancellationToken = default)Reads the body, rejecting a declared Content-Length or a streamed size above <code class=“paramref”>maxBytes</code>.
The default limit is DefaultMaxBytes. Maps to readResponseWithSizeLimit.
Parameters
| Name | Type | Description |
|---|---|---|
response |
HttpResponseMessage | |
url |
string | |
maxBytes |
long? | |
cancellationToken |
CancellationToken |
Returns: Task<byte[]>
Exceptions
| Type | Condition |
|---|---|
| DownloadError | The body is larger than the limit. |
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product