Edit

Share via


HttpClient.GetStreamAsync Method

Definition

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

Overloads

GetStreamAsync(Uri, CancellationToken)

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

GetStreamAsync(String, CancellationToken)

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

GetStreamAsync(Uri)

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

GetStreamAsync(String)

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

Remarks

The operation will not block.

GetStreamAsync(Uri, CancellationToken)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::IO::Stream ^> ^ GetStreamAsync(Uri ^ requestUri, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.IO.Stream> GetStreamAsync (Uri? requestUri, System.Threading.CancellationToken cancellationToken);
member this.GetStreamAsync : Uri * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.IO.Stream>
Public Function GetStreamAsync (requestUri As Uri, cancellationToken As CancellationToken) As Task(Of Stream)

Parameters

requestUri
Uri

The Uri the request is sent to.

cancellationToken
CancellationToken

The cancellation token to cancel the operation.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri is null.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation (or timeout for .NET Framework only).

.NET Core and .NET 5 and later only: The request failed due to timeout.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task<Stream> object will complete after the response headers are read. This method does not read nor buffer the response body.

Note

In case of a timeout:

Applies to

GetStreamAsync(String, CancellationToken)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::IO::Stream ^> ^ GetStreamAsync(System::String ^ requestUri, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<System.IO.Stream> GetStreamAsync (string? requestUri, System.Threading.CancellationToken cancellationToken);
member this.GetStreamAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.IO.Stream>
Public Function GetStreamAsync (requestUri As String, cancellationToken As CancellationToken) As Task(Of Stream)

Parameters

requestUri
String

The Uri the request is sent to.

cancellationToken
CancellationToken

The cancellation token to cancel the operation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task<Stream> object will complete after the response headers are read. This method does not read nor buffer the response body.

Note

In case of a timeout:

Applies to

GetStreamAsync(Uri)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::IO::Stream ^> ^ GetStreamAsync(Uri ^ requestUri);
public System.Threading.Tasks.Task<System.IO.Stream> GetStreamAsync (Uri requestUri);
public System.Threading.Tasks.Task<System.IO.Stream> GetStreamAsync (Uri? requestUri);
member this.GetStreamAsync : Uri -> System.Threading.Tasks.Task<System.IO.Stream>
Public Function GetStreamAsync (requestUri As Uri) As Task(Of Stream)

Parameters

requestUri
Uri

The Uri the request is sent to.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri must be an absolute URI or BaseAddress must be set.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation (or timeout for .NET Framework only).

.NET Core and .NET 5 and later only: The request failed due to timeout.

Remarks

This operation will not block. The returned Task<Stream> object will complete after the response headers are read. This method does not read nor buffer the response body.

Note

In case of a timeout:

Applies to

GetStreamAsync(String)

Source:
HttpClient.cs
Source:
HttpClient.cs
Source:
HttpClient.cs

Send a GET request to the specified Uri and return the response body as a stream in an asynchronous operation.

public:
 System::Threading::Tasks::Task<System::IO::Stream ^> ^ GetStreamAsync(System::String ^ requestUri);
public System.Threading.Tasks.Task<System.IO.Stream> GetStreamAsync (string requestUri);
public System.Threading.Tasks.Task<System.IO.Stream> GetStreamAsync (string? requestUri);
member this.GetStreamAsync : string -> System.Threading.Tasks.Task<System.IO.Stream>
Public Function GetStreamAsync (requestUri As String) As Task(Of Stream)

Parameters

requestUri
String

The Uri the request is sent to.

Returns

The task object representing the asynchronous operation.

Exceptions

The requestUri must be an absolute URI or BaseAddress must be set.

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation (or timeout for .NET Framework only).

.NET Core and .NET 5 and later only: The request failed due to timeout.

The provided request URI is not valid relative or absolute URI.

Remarks

This operation will not block. The returned Task<Stream> object will complete after the response headers are read. This method does not read nor buffer the response body.

Note

In case of a timeout:

Applies to