Remove unused methods from HttpRequestMessageExtensions.
MODIFY
WalletWasabi/Tor/Http/Extensions/HttpRequestMessageExtensions.cs
WalletWasabi/Tor/Http/Extensions/HttpRequestMessageExtensions.cs
-using System.IO;
using System.Linq;
using System.Net.Http;
-using System.Threading;
using System.Threading.Tasks;
-using WalletWasabi.Tor.Http.Helpers;
using WalletWasabi.Tor.Http.Models;
using static WalletWasabi.Tor.Http.Constants;
@@ -11,50 +8,6 @@ namespace WalletWasabi.Tor.Http.Extensions
{
public static class HttpRequestMessageExtensions
{
- public static async Task<HttpRequestMessage> CreateNewAsync(Stream requestStream, CancellationToken ctsToken = default)
- {
- // https://tools.ietf.org/html/rfc7230#section-3
- // The normal procedure for parsing an HTTP message is to read the
- // start - line into a structure, read each header field into a hash table
- // by field name until the empty line, and then use the parsed data to
- // determine if a message body is expected.If a message body has been
- // indicated, then it is read as a stream until an amount of octets
- // equal to the message body length is read or the connection is closed.
-
- // https://tools.ietf.org/html/rfc7230#section-3
- // All HTTP/ 1.1 messages consist of a start - line followed by a sequence
- // of octets in a format similar to the Internet Message Format
- // [RFC5322]: zero or more header fields(collectively referred to as
- // the "headers" or the "header section"), an empty line indicating the
- // end of the header section, and an optional message body.
- // HTTP - message = start - line
- // * (header - field CRLF )
- // CRLF
- // [message - body]
-
- string startLine = await HttpMessageHelper.ReadStartLineAsync(requestStream, ctsToken).ConfigureAwait(false);
-
- var requestLine = RequestLine.Parse(startLine);
- var request = new HttpRequestMessage(requestLine.Method, requestLine.URI);
-
- string headers = await HttpMessageHelper.ReadHeadersAsync(requestStream, ctsToken).ConfigureAwait(false);
-
- var headerSection = await HeaderSection.CreateNewAsync(headers).ConfigureAwait(false);
- var headerStruct = headerSection.ToHttpRequestHeaders();
-
- HttpMessageHelper.AssertValidHeaders(headerStruct.RequestHeaders, headerStruct.ContentHeaders);
- byte[] contentBytes = await HttpMessageHelper.GetContentBytesAsync(requestStream, headerStruct, ctsToken).ConfigureAwait(false);
- contentBytes = HttpMessageHelper.HandleGzipCompression(headerStruct.ContentHeaders, contentBytes);
- request.Content = contentBytes is null ? null : new ByteArrayContent(contentBytes);
-
- HttpMessageHelper.CopyHeaders(headerStruct.RequestHeaders, request.Headers);
- if (request.Content is { })
- {
- HttpMessageHelper.CopyHeaders(headerStruct.ContentHeaders, request.Content.Headers);
- }
- return request;
- }
-
public static async Task<string> ToHttpStringAsync(this HttpRequestMessage me)
{
// https://tools.ietf.org/html/rfc7230#section-5.4
@@ -102,37 +55,5 @@ namespace WalletWasabi.Tor.Http.Extensions
return startLine + headers + CRLF + messageBody;
}
-
- public static async Task<HttpRequestMessage> CloneAsync(this HttpRequestMessage me)
- {
- var newMessage = new HttpRequestMessage(me.Method, me.RequestUri)
- {
- Version = me.Version
- };
-
- foreach (var header in me.Headers)
- {
- newMessage.Headers.TryAddWithoutValidation(header.Key, header.Value);
- }
-
- if (me.Content is null)
- {
- return newMessage;
- }
-
- var ms = new MemoryStream();
- await me.Content.CopyToAsync(ms).ConfigureAwait(false);
- ms.Position = 0;
- var newContent = new StreamContent(ms);
-
- foreach (var header in me.Content.Headers)
- {
- newContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
- }
-
- newMessage.Content = newContent;
-
- return newMessage;
- }
}
}

Remove unused methods from HttpRequestMessageExtensions.