I'm trying to set the request headers for the below request, but get an error that the names client and request do not exist in the current context. How do I configure these additional parameters?
public static async Task<string> HttpGetRemoteFileAsync(Uri resourceUri, CancellationToken cancellationToken)
{
string result = null;
using (var client = new HttpClient())
using (request = new HttpRequestMessage(HttpMethod.Get, resourceUri))
{
request.Headers.UserAgent.Add(new ProductInfoHeaderValue(new ProductHeaderValue("HeaderValue")));
}
using (
Stream contentStream = await (await client.SendAsync(request, cancellationToken)).Content.ReadAsStreamAsync())
{
var content = new HttpRequestStreamReader(contentStream, System.Text.UTF8Encoding.UTF8);
result = await content.ReadToEndAsync();
}
return result;
}