mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-12 00:43:03 +00:00
d44a11c44e
Added LibraryHelpers.CreateHttpClientMessageHandle to standardize HttpMessageHandler creation Added REST client option for selecting HTTP protocol version Added REST client option for HTTP client keep alive interval Added HttpVersion to WebCallResult responses Updated request logic to default to using HTTP version 2.0 for dotnet core
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using CryptoExchange.Net.Interfaces;
|
|
|
|
namespace CryptoExchange.Net.Requests
|
|
{
|
|
/// <summary>
|
|
/// Response object, wrapper for HttpResponseMessage
|
|
/// </summary>
|
|
internal class Response : IResponse
|
|
{
|
|
private readonly HttpResponseMessage _response;
|
|
|
|
/// <inheritdoc />
|
|
public HttpStatusCode StatusCode => _response.StatusCode;
|
|
|
|
/// <inheritdoc />
|
|
public Version HttpVersion => _response.Version;
|
|
|
|
/// <inheritdoc />
|
|
public bool IsSuccessStatusCode => _response.IsSuccessStatusCode;
|
|
|
|
/// <inheritdoc />
|
|
public long? ContentLength => _response.Content.Headers.ContentLength;
|
|
|
|
/// <inheritdoc />
|
|
public KeyValuePair<string, string[]>[] ResponseHeaders => _response.Headers.Select(x => new KeyValuePair<string, string[]>(x.Key, x.Value.ToArray())).ToArray();
|
|
|
|
/// <summary>
|
|
/// Create response for a http response message
|
|
/// </summary>
|
|
/// <param name="response">The actual response</param>
|
|
public Response(HttpResponseMessage response)
|
|
{
|
|
this._response = response;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<Stream> GetResponseStreamAsync()
|
|
{
|
|
return await _response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Close()
|
|
{
|
|
_response.Dispose();
|
|
}
|
|
}
|
|
}
|