1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-09 08:56:13 +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); void SetProxy(string host, int port);
string ContentType { get; set; } string ContentType { get; set; }
string Content { get; set; }
string Accept { get; set; } string Accept { get; set; }
long ContentLength { get; set; } long ContentLength { get; set; }

View File

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

View File

@ -146,15 +146,8 @@ namespace CryptoExchange.Net
} }
string paramString = null; string paramString = null;
if (parameters != null) if (parameters != null && method == Constants.PostMethod)
{ paramString = "with request body " + request.Content;
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(',');
}
log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri} {paramString ?? ""}"); log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri} {paramString ?? ""}");
var result = await ExecuteRequest(request).ConfigureAwait(false); var result = await ExecuteRequest(request).ConfigureAwait(false);
@ -233,7 +226,7 @@ namespace CryptoExchange.Net
{ {
var data = Encoding.UTF8.GetBytes(stringData); var data = Encoding.UTF8.GetBytes(stringData);
request.ContentLength = data.Length; request.ContentLength = data.Length;
request.Content = stringData;
using (var stream = request.GetRequestStream().Result) using (var stream = request.GetRequestStream().Result)
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }