|
|
@ -284,9 +284,10 @@ namespace Emby.Server.Implementations.HttpClientManager
|
|
|
|
|
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
|
|
if (!options.BufferContent)
|
|
|
|
var response = await client.SendAsync(
|
|
|
|
{
|
|
|
|
httpWebRequest,
|
|
|
|
var response = await client.SendAsync(httpWebRequest, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false);
|
|
|
|
options.BufferContent ? HttpCompletionOption.ResponseContentRead : HttpCompletionOption.ResponseHeadersRead,
|
|
|
|
|
|
|
|
options.CancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
await EnsureSuccessStatusCode(response, options).ConfigureAwait(false);
|
|
|
|
await EnsureSuccessStatusCode(response, options).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
@ -303,30 +304,6 @@ namespace Emby.Server.Implementations.HttpClientManager
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var response = await client.SendAsync(httpWebRequest, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken).ConfigureAwait(false))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await EnsureSuccessStatusCode(response, options).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.CancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var memoryStream = new MemoryStream();
|
|
|
|
|
|
|
|
await stream.CopyToAsync(memoryStream, StreamDefaults.DefaultCopyToBufferSize, options.CancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
memoryStream.Position = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpResponseInfo(response.Headers, response.Content.Headers)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Content = memoryStream,
|
|
|
|
|
|
|
|
StatusCode = response.StatusCode,
|
|
|
|
|
|
|
|
ContentType = response.Content.Headers.ContentType?.MediaType,
|
|
|
|
|
|
|
|
ContentLength = memoryStream.Length,
|
|
|
|
|
|
|
|
ResponseUrl = response.Content.Headers.ContentLocation?.ToString()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Task<HttpResponseInfo> Post(HttpRequestOptions options)
|
|
|
|
public Task<HttpResponseInfo> Post(HttpRequestOptions options)
|
|
|
|
=> SendAsync(options, HttpMethod.Post);
|
|
|
|
=> SendAsync(options, HttpMethod.Post);
|
|
|
|
|
|
|
|
|
|
|
|