mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 08:26:20 +00:00
resync
This commit is contained in:
parent
9b8950747f
commit
fb61b6931b
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ namespace CryptoExchange.Net.Interfaces
|
||||
/// <summary>
|
||||
/// internal request id for tracing
|
||||
/// </summary>
|
||||
string? RequestId { get; }
|
||||
string RequestId { get; }
|
||||
/// <summary>
|
||||
/// Set byte content
|
||||
/// </summary>
|
||||
|
@ -21,8 +21,7 @@ namespace CryptoExchange.Net.Interfaces
|
||||
/// Configure the requests created by this factory
|
||||
/// </summary>
|
||||
/// <param name="requestTimeout">Request timeout to use</param>
|
||||
/// <param name="proxy">Proxy settings to use</param>
|
||||
/// <param name="isTracingEnabled">Should generate unique id for requests</param>
|
||||
void Configure(TimeSpan requestTimeout, ApiProxy? proxy, bool isTracingEnabled=false);
|
||||
/// <param name="proxy">Proxy settings to use</param>
|
||||
void Configure(TimeSpan requestTimeout, ApiProxy? proxy);
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace CryptoExchange.Net.Objects
|
||||
/// The time the server has to respond to a request before timing out
|
||||
/// </summary>
|
||||
public TimeSpan RequestTimeout { get; set; } = TimeSpan.FromSeconds(30);
|
||||
public bool IsRequestsTracingEnabled { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
@ -21,16 +21,12 @@ namespace CryptoExchange.Net.Requests
|
||||
/// Create request object for web request
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="isTracingEnabled">if true, should assign unique id for request</param>
|
||||
public Request(HttpRequestMessage request, HttpClient client, bool isTracingEnabled=false)
|
||||
/// <param name="client"></param>
|
||||
public Request(HttpRequestMessage request, HttpClient client)
|
||||
{
|
||||
httpClient = client;
|
||||
this.request = request;
|
||||
if (isTracingEnabled)
|
||||
{
|
||||
RequestId = Path.GetRandomFileName();
|
||||
}
|
||||
RequestId = Path.GetRandomFileName();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -52,7 +48,7 @@ namespace CryptoExchange.Net.Requests
|
||||
/// <inheritdoc />
|
||||
public Uri Uri => request.RequestUri;
|
||||
/// <inheritdoc />
|
||||
public string? RequestId { get; }
|
||||
public string RequestId { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetContent(string data, string contentType)
|
||||
|
@ -14,9 +14,8 @@ namespace CryptoExchange.Net.Requests
|
||||
private HttpClient? httpClient;
|
||||
private bool isTracingEnabled;
|
||||
/// <inheritdoc />
|
||||
public void Configure(TimeSpan requestTimeout, ApiProxy? proxy, bool isTracingEnabled = false)
|
||||
{
|
||||
this.isTracingEnabled = isTracingEnabled;
|
||||
public void Configure(TimeSpan requestTimeout, ApiProxy? proxy)
|
||||
{
|
||||
HttpMessageHandler handler = new HttpClientHandler()
|
||||
{
|
||||
Proxy = proxy == null ? null : new WebProxy
|
||||
@ -35,7 +34,7 @@ namespace CryptoExchange.Net.Requests
|
||||
if (httpClient == null)
|
||||
throw new InvalidOperationException("Cant create request before configuring http client");
|
||||
|
||||
return new Request(new HttpRequestMessage(method, uri), httpClient, isTracingEnabled);
|
||||
return new Request(new HttpRequestMessage(method, uri), httpClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ namespace CryptoExchange.Net
|
||||
throw new ArgumentNullException(nameof(exchangeOptions));
|
||||
|
||||
RequestTimeout = exchangeOptions.RequestTimeout;
|
||||
RequestFactory.Configure(exchangeOptions.RequestTimeout, exchangeOptions.Proxy,exchangeOptions.IsRequestsTracingEnabled);
|
||||
RequestFactory.Configure(exchangeOptions.RequestTimeout, exchangeOptions.Proxy);
|
||||
RateLimitBehaviour = exchangeOptions.RateLimitingBehaviour;
|
||||
var rateLimiters = new List<IRateLimiter>();
|
||||
foreach (var rateLimiter in exchangeOptions.RateLimiters)
|
||||
@ -197,7 +197,7 @@ namespace CryptoExchange.Net
|
||||
if (method == HttpMethod.Post)
|
||||
paramString = " with request body " + request.Content;
|
||||
|
||||
log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri}{paramString ?? " "}{(apiProxy == null? "": $" via proxy {apiProxy.Host}")} {(request.RequestId==null?"":$" with id {request.RequestId}")}");
|
||||
log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri}{paramString ?? " "}{(apiProxy == null? "": $" via proxy {apiProxy.Host}")} with id {request.RequestId}");
|
||||
return await GetResponse<T>(request, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ namespace CryptoExchange.Net
|
||||
var data = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
responseStream.Close();
|
||||
response.Close();
|
||||
log.Write(LogVerbosity.Debug, $"Data {(request.RequestId==null?"":$"for request {request.RequestId} ")}received: {data}");
|
||||
log.Write(LogVerbosity.Debug, $"Data for request {request.RequestId} received: {data}");
|
||||
|
||||
var parseResult = ValidateJson(data);
|
||||
if (!parseResult.Success)
|
||||
@ -249,7 +249,7 @@ namespace CryptoExchange.Net
|
||||
{
|
||||
using var reader = new StreamReader(responseStream);
|
||||
var data = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
log.Write(LogVerbosity.Debug, $"Error {(request.RequestId == null ? "" : $"for request {request.RequestId} ")}received: {data}");
|
||||
log.Write(LogVerbosity.Debug, $"Error for request {request.RequestId} received: {data}");
|
||||
responseStream.Close();
|
||||
response.Close();
|
||||
var parseResult = ValidateJson(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user