1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-09 00:46:19 +00:00

Made parameter logging use actually json data for post requests

This commit is contained in:
Jan Korf 2019-02-01 17:40:51 +01:00
parent 0229405775
commit 74d3f692b9
3 changed files with 7 additions and 11 deletions

View File

@ -14,6 +14,7 @@ namespace CryptoExchange.Net.Interfaces
void SetProxy(string host, int port);
string ContentType { get; set; }
string Content { get; set; }
string Accept { get; set; }
long ContentLength { get; set; }

View File

@ -26,6 +26,8 @@ namespace CryptoExchange.Net.Requests
set => request.ContentType = value;
}
public string Content { get; set; }
public string Accept
{
get => ((HttpWebRequest)request).Accept;

View File

@ -146,15 +146,8 @@ namespace CryptoExchange.Net
}
string paramString = null;
if (parameters != null)
{
paramString = "with parameters";
foreach (var param in parameters)
paramString += $" {param.Key}={(param.Value.GetType().IsArray ? $"[{string.Join(", ", ((object[])param.Value).Select(p => p.ToString()))}]": param.Value )},";
paramString = paramString.Trim(',');
}
if (parameters != null && method == Constants.PostMethod)
paramString = "with request body " + request.Content;
log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri} {paramString ?? ""}");
var result = await ExecuteRequest(request).ConfigureAwait(false);
@ -233,7 +226,7 @@ namespace CryptoExchange.Net
{
var data = Encoding.UTF8.GetBytes(stringData);
request.ContentLength = data.Length;
request.Content = stringData;
using (var stream = request.GetRequestStream().Result)
stream.Write(data, 0, data.Length);
}