mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-11 18:06:27 +00:00
Added a flexible way to write in request body
This commit is contained in:
parent
2ff2912fb3
commit
9030ffd333
@ -143,6 +143,7 @@ namespace CryptoExchange.Net
|
|||||||
|
|
||||||
var request = RequestFactory.Create(uriString);
|
var request = RequestFactory.Create(uriString);
|
||||||
request.Method = method;
|
request.Method = method;
|
||||||
|
request.Parameters = parameters;
|
||||||
|
|
||||||
if (authProvider != null)
|
if (authProvider != null)
|
||||||
request = authProvider.AddAuthenticationToRequest(request, signed);
|
request = authProvider.AddAuthenticationToRequest(request, signed);
|
||||||
@ -155,6 +156,15 @@ namespace CryptoExchange.Net
|
|||||||
var returnedData = "";
|
var returnedData = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (request.WriteCustomBody &&
|
||||||
|
request.CustomBody != null && request.CustomBody.Length > 0)
|
||||||
|
{
|
||||||
|
using (var requestStream = await request.GetRequestStream())
|
||||||
|
{
|
||||||
|
requestStream.Write(request.CustomBody, 0, request.CustomBody.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var response = await request.GetResponse().ConfigureAwait(false);
|
var response = await request.GetResponse().ConfigureAwait(false);
|
||||||
using (var reader = new StreamReader(response.GetResponseStream()))
|
using (var reader = new StreamReader(response.GetResponseStream()))
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,6 +11,10 @@ namespace CryptoExchange.Net.Interfaces
|
|||||||
Uri Uri { get; }
|
Uri Uri { get; }
|
||||||
WebHeaderCollection Headers { get; set; }
|
WebHeaderCollection Headers { get; set; }
|
||||||
string Method { get; set; }
|
string Method { get; set; }
|
||||||
|
Dictionary<string, object> Parameters { get; set; }
|
||||||
|
|
||||||
|
byte[] CustomBody { get; set; }
|
||||||
|
bool WriteCustomBody { get; set; }
|
||||||
|
|
||||||
void SetProxy(string host, int port);
|
void SetProxy(string host, int port);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -44,6 +45,11 @@ namespace CryptoExchange.Net.Requests
|
|||||||
set => request.Method = value;
|
set => request.Method = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, object> Parameters { get; set; }
|
||||||
|
|
||||||
|
public byte[] CustomBody { get; set; }
|
||||||
|
public bool WriteCustomBody { get; set; } = false;
|
||||||
|
|
||||||
public Uri Uri => request.RequestUri;
|
public Uri Uri => request.RequestUri;
|
||||||
|
|
||||||
public void SetProxy(string host, int port)
|
public void SetProxy(string host, int port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user