Add TorSocks5Client, Remove ConfigureAwaits
MODIFY
MagicalCryptoWallet/Extensions/HttpRequestMessageExtensions.cs
MagicalCryptoWallet/Extensions/HttpRequestMessageExtensions.cs
@@ -31,20 +31,20 @@ namespace System.Net.Http
// [message - body]
var position = 0;
- string startLine = await HttpMessageHelper.ReadStartLineAsync(requestStream, ctsToken).ConfigureAwait(false);
+ string startLine = await HttpMessageHelper.ReadStartLineAsync(requestStream, ctsToken);
position += startLine.Length;
var requestLine = RequestLine.CreateNew(startLine);
var request = new HttpRequestMessage(requestLine.Method, requestLine.URI);
- string headers = await HttpMessageHelper.ReadHeadersAsync(requestStream, ctsToken).ConfigureAwait(false);
+ string headers = await HttpMessageHelper.ReadHeadersAsync(requestStream, ctsToken);
position += headers.Length + 2;
var headerSection = HeaderSection.CreateNew(headers);
var headerStruct = headerSection.ToHttpRequestHeaders();
HttpMessageHelper.AssertValidHeaders(headerStruct.RequestHeaders, headerStruct.ContentHeaders);
- request.Content = await HttpMessageHelper.GetContentAsync(requestStream, headerStruct, ctsToken).ConfigureAwait(false);
+ request.Content = await HttpMessageHelper.GetContentAsync(requestStream, headerStruct, ctsToken);
HttpMessageHelper.CopyHeaders(headerStruct.RequestHeaders, request.Headers);
if (request.Content != null)
@@ -96,7 +96,7 @@ namespace System.Net.Http
headers += headerSection.ToString(endWithTwoCRLF: false);
}
- messageBody = await me.Content.ReadAsStringAsync().ConfigureAwait(false);
+ messageBody = await me.Content.ReadAsStringAsync();
}
return startLine + headers + CRLF + messageBody;

MODIFY
MagicalCryptoWallet/Extensions/HttpResponseMessageExtensions.cs
MagicalCryptoWallet/Extensions/HttpResponseMessageExtensions.cs
@@ -31,20 +31,20 @@ namespace System.Net.Http
// [message - body]
var position = 0;
- string startLine = await HttpMessageHelper.ReadStartLineAsync(responseStream).ConfigureAwait(false);
+ string startLine = await HttpMessageHelper.ReadStartLineAsync(responseStream);
position += startLine.Length;
var statusLine = StatusLine.CreateNew(startLine);
var response = new HttpResponseMessage(statusLine.StatusCode);
- string headers = await HttpMessageHelper.ReadHeadersAsync(responseStream).ConfigureAwait(false);
+ string headers = await HttpMessageHelper.ReadHeadersAsync(responseStream);
position += headers.Length + 2;
var headerSection = HeaderSection.CreateNew(headers);
var headerStruct = headerSection.ToHttpResponseHeaders();
HttpMessageHelper.AssertValidHeaders(headerStruct.ResponseHeaders, headerStruct.ContentHeaders);
- response.Content = await HttpMessageHelper.GetContentAsync(responseStream, headerStruct, requestMethod, statusLine).ConfigureAwait(false);
+ response.Content = await HttpMessageHelper.GetContentAsync(responseStream, headerStruct, requestMethod, statusLine);
HttpMessageHelper.CopyHeaders(headerStruct.ResponseHeaders, response.Headers);
if (response.Content != null)
@@ -56,7 +56,7 @@ namespace System.Net.Http
public static async Task<Stream> ToStreamAsync(this HttpResponseMessage me)
{
- return new MemoryStream(Encoding.UTF8.GetBytes(await me.ToHttpStringAsync().ConfigureAwait(false)));
+ return new MemoryStream(Encoding.UTF8.GetBytes(await me.ToHttpStringAsync()));
}
public static async Task<string> ToHttpStringAsync(this HttpResponseMessage me)
{
@@ -78,7 +78,7 @@ namespace System.Net.Http
headers += headerSection.ToString(endWithTwoCRLF: false);
}
- messageBody = await me.Content.ReadAsStringAsync().ConfigureAwait(false);
+ messageBody = await me.Content.ReadAsStringAsync();
}
return startLine + headers + CRLF + messageBody;

MODIFY
MagicalCryptoWallet/Extensions/StreamExtensions.cs
MagicalCryptoWallet/Extensions/StreamExtensions.cs
@@ -17,7 +17,7 @@ namespace System.IO
var left = count;
while(left != 0)
{
- var read = await stream.ReadAsync(buffer, count - left, left, ctsToken).ConfigureAwait(false);
+ var read = await stream.ReadAsync(buffer, count - left, left, ctsToken);
left -= read;
}
return count - left;

MODIFY
MagicalCryptoWallet/Helpers/HttpMessageHelper.cs
MagicalCryptoWallet/Helpers/HttpMessageHelper.cs
@@ -28,7 +28,7 @@ namespace System.Net.Http
int read = 0;
while (read >= 0)
{
- read = await stream.ReadByteAsync(ctsToken).ConfigureAwait(false);
+ read = await stream.ReadByteAsync(ctsToken);
bab.Append((byte)read);
if (Encoding.ASCII.GetBytes(LF)[0] == (byte)read)
{
@@ -87,12 +87,12 @@ namespace System.Net.Http
var bab = new ByteArrayBuilder();
while (true)
{
- int ch = await stream.ReadByteAsync(ctsToken).ConfigureAwait(false);
+ int ch = await stream.ReadByteAsync(ctsToken);
if (ch == -1) break;
if (ch == '\r')
{
- var ch2 = await stream.ReadByteAsync(ctsToken).ConfigureAwait(false);
+ var ch2 = await stream.ReadByteAsync(ctsToken);
if (ch2 == '\n')
{
return bab.ToString(encoding);
@@ -121,7 +121,7 @@ namespace System.Net.Http
// All transfer-coding names are case-insensitive
if ("chunked".Equals(headerStruct.RequestHeaders.TransferEncoding.Last().Value, StringComparison.OrdinalIgnoreCase))
{
- return await GetDecodedChunkedContentAsync(stream, headerStruct, ctsToken).ConfigureAwait(false);
+ return await GetDecodedChunkedContentAsync(stream, headerStruct, ctsToken);
}
// https://tools.ietf.org/html/rfc7230#section-3.3.3
// If a Transfer - Encoding header field is present in a response and
@@ -134,7 +134,7 @@ namespace System.Net.Http
// status code and then close the connection.
else
{
- return await GetContentTillEndAsync(stream, ctsToken).ConfigureAwait(false);
+ return await GetContentTillEndAsync(stream, ctsToken);
}
}
// https://tools.ietf.org/html/rfc7230#section-3.3.3
@@ -147,7 +147,7 @@ namespace System.Net.Http
else if (headerStruct.ContentHeaders.Contains("Content-Length"))
{
long? contentLength = headerStruct.ContentHeaders?.ContentLength;
- return await GetContentTillLengthAsync(stream, contentLength, ctsToken).ConfigureAwait(false);
+ return await GetContentTillLengthAsync(stream, contentLength, ctsToken);
}
// https://tools.ietf.org/html/rfc7230#section-3.3.3
@@ -201,7 +201,7 @@ namespace System.Net.Http
// All transfer-coding names are case-insensitive
if ("chunked".Equals(headerStruct.ResponseHeaders.TransferEncoding.Last().Value, StringComparison.OrdinalIgnoreCase))
{
- return await GetDecodedChunkedContentAsync(stream, headerStruct, ctsToken).ConfigureAwait(false);
+ return await GetDecodedChunkedContentAsync(stream, headerStruct, ctsToken);
}
// https://tools.ietf.org/html/rfc7230#section-3.3.3
// If a Transfer - Encoding header field is present in a response and
@@ -214,7 +214,7 @@ namespace System.Net.Http
// status code and then close the connection.
else
{
- return await GetContentTillEndAsync(stream, ctsToken).ConfigureAwait(false);
+ return await GetContentTillEndAsync(stream, ctsToken);
}
}
// https://tools.ietf.org/html/rfc7230#section-3.3.3
@@ -228,7 +228,7 @@ namespace System.Net.Http
{
long? contentLength = headerStruct.ContentHeaders?.ContentLength;
- return await GetContentTillLengthAsync(stream, contentLength, ctsToken).ConfigureAwait(false);
+ return await GetContentTillLengthAsync(stream, contentLength, ctsToken);
}
// https://tools.ietf.org/html/rfc7230#section-3.3.3
@@ -238,16 +238,16 @@ namespace System.Net.Http
// body length, so the message body length is determined by the
// number of octets received prior to the server closing the
// connection.
- return await GetContentTillEndAsync(stream, ctsToken).ConfigureAwait(false);
+ return await GetContentTillEndAsync(stream, ctsToken);
}
private static async Task<HttpContent> GetDecodedChunkedContentAsync(Stream stream, HttpRequestContentHeaders headerStruct, CancellationToken ctsToken = default)
{
- return await GetDecodedChunkedContentAsync(stream, headerStruct, null, ctsToken).ConfigureAwait(false);
+ return await GetDecodedChunkedContentAsync(stream, headerStruct, null, ctsToken);
}
private static async Task<HttpContent> GetDecodedChunkedContentAsync(Stream stream, HttpResponseContentHeaders headerStruct, CancellationToken ctsToken = default)
{
- return await GetDecodedChunkedContentAsync(stream, null, headerStruct, ctsToken).ConfigureAwait(false);
+ return await GetDecodedChunkedContentAsync(stream, null, headerStruct, ctsToken);
}
private static async Task<HttpContent> GetDecodedChunkedContentAsync(Stream stream, HttpRequestContentHeaders requestHeaders, HttpResponseContentHeaders responseHeaders, CancellationToken ctsToken = default)
{
@@ -284,7 +284,7 @@ namespace System.Net.Http
// Remove "chunked" from Transfer-Encoding
// Remove Trailer from existing header fields
long length = 0;
- var firstChunkLine = await ReadCRLFLineAsync(stream, Encoding.ASCII, ctsToken: ctsToken).ConfigureAwait(false);
+ var firstChunkLine = await ReadCRLFLineAsync(stream, Encoding.ASCII, ctsToken: ctsToken);
ParseFistChunkLine(firstChunkLine, out long chunkSize, out IEnumerable<string> chunkExtensions);
// We will not do anything with the chunk extensions, because:
// https://tools.ietf.org/html/rfc7230#section-4.1.1
@@ -297,8 +297,8 @@ namespace System.Net.Http
// by a trailer, and finally terminated by an empty line.
while (chunkSize > 0)
{
- var chunkData = await ReadBytesTillLengthAsync(stream, chunkSize, ctsToken).ConfigureAwait(false);
- if (await ReadCRLFLineAsync(stream, Encoding.ASCII, ctsToken).ConfigureAwait(false) != "")
+ var chunkData = await ReadBytesTillLengthAsync(stream, chunkSize, ctsToken);
+ if (await ReadCRLFLineAsync(stream, Encoding.ASCII, ctsToken) != "")
{
throw new FormatException("Chunk does not end with CRLF.");
}
@@ -310,7 +310,7 @@ namespace System.Net.Http
length += chunkSize;
- firstChunkLine = await ReadCRLFLineAsync(stream, Encoding.ASCII, ctsToken: ctsToken).ConfigureAwait(false);
+ firstChunkLine = await ReadCRLFLineAsync(stream, Encoding.ASCII, ctsToken: ctsToken);
ParseFistChunkLine(firstChunkLine, out long cs, out IEnumerable<string> ces);
chunkSize = cs;
chunkExtensions = ces;
@@ -319,7 +319,7 @@ namespace System.Net.Http
// A trailer allows the sender to include additional fields at the end
// of a chunked message in order to supply metadata that might be
// dynamically generated while the message body is sent
- string trailerHeaders = await ReadHeadersAsync(stream, ctsToken).ConfigureAwait(false);
+ string trailerHeaders = await ReadHeadersAsync(stream, ctsToken);
var trailerHeaderSection = HeaderSection.CreateNew(trailerHeaders);
RemoveInvalidTrailers(trailerHeaderSection);
if (responseHeaders != null)
@@ -429,13 +429,13 @@ namespace System.Net.Http
var bab = new ByteArrayBuilder();
while(true)
{
- var read = await stream.ReadByteAsync(ctsToken).ConfigureAwait(false);
+ var read = await stream.ReadByteAsync(ctsToken);
if (read == -1) return new ByteArrayContent(bab.ToArray());
}
}
private static async Task<HttpContent> GetContentTillLengthAsync(Stream stream, long? contentLength, CancellationToken ctsToken = default)
- => new ByteArrayContent(await ReadBytesTillLengthAsync(stream, contentLength, ctsToken).ConfigureAwait(false));
+ => new ByteArrayContent(await ReadBytesTillLengthAsync(stream, contentLength, ctsToken));
private static async Task<byte[]> ReadBytesTillLengthAsync(Stream stream, long? length, CancellationToken ctsToken)
{
@@ -450,7 +450,7 @@ namespace System.Net.Http
}
var allData = new byte[(int)length];
- var num = await stream.ReadBlockAsync(allData, 0, (int)length).ConfigureAwait(false);
+ var num = await stream.ReadBlockAsync(allData, 0, (int)length);
if (num < (int)length)
{
// https://tools.ietf.org/html/rfc7230#section-3.3.3

Add TorSocks5Client, Remove ConfigureAwaits