Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Permalink
docs
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
-api-id -api-type ms.custom
M:Windows.Web.Http.HttpClient.TryGetBufferAsync(Windows.Foundation.Uri)
winrt method
19H1

Windows.Web.Http.HttpClient.TryGetBufferAsync

-description

Send a GET request to the specified Uri and return the response body as HttpGetBufferResult with an IBuffer value in an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

-parameters

-param uri

The Uri the request is sent to.

-returns

The object representing the asynchronous operation.

-remarks

This method is commonly called when downloading binary content such as small images and compressed files. Very large binary content should be downloaded as a stream with HttpClient.TryGetInputStreamAsync to prevent unneeded buffering.

This operation will not block. The returned IAsyncOperationWithProgress (of HttpGetBufferResult and HttpProgress) completes after the whole response body is read.

The HttpClient class is often used by an app to download and then parse text. It is possible that the character encoding specified in the Content-Type header by an HTTP server does not match the character encoding of the HTTP response body (the XML encoding in an XML document, for example). One way to use HttpClient with text is to call the TryGetStringAsync method and pass the returned string to the text parser. However, this can result in errors if the Content-Type is not a type expressible as a string. A reliable way to use HttpClient with an XML parser is to call the TryGetBufferAsync method and parse the buffer for the "<?xml>" element. Then use the character encoding specified ("<xmlversion="1.0" encoding="UTF-8"?>", for example) to parse the HTTP response body. For other text formats, similar methods can be used where the app scans the initial part of the HTTP response body to determine the character encoding used.

-see-also

HttpGetBufferResult, HttpProgress, IBuffer, HttpClient.TryGetInputStreamAsync, HttpClient

-examples