in WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs [49:92]
private async Task<Stream> PostAsync(
Uri uri,
HttpContent requestContent)
{
MemoryStream dataStream = null;
WebRequestHandler requestSettings = new WebRequestHandler();
requestSettings.UseDefaultCredentials = false;
requestSettings.Credentials = this.deviceConnection.Credentials;
requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
using (HttpClient client = new HttpClient(requestSettings))
{
this.ApplyHttpHeaders(client, HttpMethods.Post);
Task<HttpResponseMessage> postTask = TestHelpers.MockHttpResponder.PostAsync(uri, requestContent);
await postTask.ConfigureAwait(false);
postTask.Wait();
using (HttpResponseMessage response = postTask.Result)
{
if (!response.IsSuccessStatusCode)
{
throw await DevicePortalException.CreateAsync(response);
}
if (response.Content != null)
{
using (HttpContent content = response.Content)
{
dataStream = new MemoryStream();
Task copyTask = content.CopyToAsync(dataStream);
await copyTask.ConfigureAwait(false);
copyTask.Wait();
// Ensure we return with the stream pointed at the origin.
dataStream.Position = 0;
}
}
}
}
return dataStream;
}