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)
GetStreamAsync(String, CancellationToken)
GetStreamAsync(String)

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.

Remarks

The operation will not block.

GetStreamAsync(Uri, CancellationToken)

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
cancellationToken
CancellationToken

Returns

Task<Stream>

GetStreamAsync(String, CancellationToken)

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
cancellationToken
CancellationToken

Returns

Task<Stream>

GetStreamAsync(String)

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

Task<Stream>

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.

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

Remarks

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

Note

In case of timeout, different exceptions are thrown on different .NET implementations.

GetStreamAsync(Uri)

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

Task<Stream>

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.

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

Remarks

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

Note

In case of timeout, different exceptions are thrown on different .NET implementations.

Applies to