Skip to content

Commit

Permalink
Revert "MapArrayAsync -> WIP"
Browse files Browse the repository at this point in the history
This reverts commit 5bcc611.
  • Loading branch information
LBoullosa committed Aug 24, 2024
1 parent 5bcc611 commit 2a8ad28
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// ----------------------------------------------------------------------------------

using System.Net.Http.Headers;
using System.Threading.Tasks;
using STX.REST.RESTFulSense.Clients.Models.Services.HttpExchanges.Headers;

namespace STX.REST.RESTFulSense.Clients.Services.Foundations.HttpExchanges
Expand All @@ -23,7 +22,7 @@ private static NameValueHeader MapToNameValueHeader(
};
}

private static async ValueTask<TransferCodingHeader> MapToTransferCodingHeader(
private static TransferCodingHeader MapToTransferCodingHeader(
TransferCodingHeaderValue transferCodingHeaderValue)
{
if (transferCodingHeaderValue is null)
Expand All @@ -33,7 +32,7 @@ private static async ValueTask<TransferCodingHeader> MapToTransferCodingHeader(
{
Value = transferCodingHeaderValue.Value,
Parameters =
await MapArrayAsync(
MapArray(
transferCodingHeaderValue.Parameters,
MapToNameValueHeader)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using STX.REST.RESTFulSense.Clients.Models.Services.HttpExchanges;

namespace STX.REST.RESTFulSense.Clients.Services.Foundations.HttpExchanges
Expand Down Expand Up @@ -267,7 +266,7 @@ private static void MapToHttpRequestHeaders(
}
}

private static async ValueTask<HttpExchangeResponseHeaders> MapHttpExchangeResponseHeaders(
private static HttpExchangeResponseHeaders MapHttpExchangeResponseHeaders(
HttpResponseHeaders httpResponseHeaders)
{
if (httpResponseHeaders is null)
Expand All @@ -276,7 +275,7 @@ private static async ValueTask<HttpExchangeResponseHeaders> MapHttpExchangeRespo
return new HttpExchangeResponseHeaders
{
AcceptRanges =
await MapArrayAsync(
MapArray(
httpResponseHeaders.AcceptRanges,
@string => @string),

Expand All @@ -287,7 +286,7 @@ await MapArrayAsync(
httpResponseHeaders.CacheControl),

Connection =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Connection,
@string => @string),

Expand All @@ -297,12 +296,12 @@ await MapArrayAsync(
Location = httpResponseHeaders.Location,

Pragma =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Pragma,
MapToNameValueHeader),

ProxyAuthenticate =
await MapArrayAsync(
MapArray(
httpResponseHeaders.ProxyAuthenticate,
MapToAuthenticationHeader),

Expand All @@ -311,51 +310,51 @@ await MapArrayAsync(
httpResponseHeaders.RetryAfter),

Server =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Server,
MapToProductInfoHeader),

Trailer =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Trailer,
@string => @string),

TransferEncoding =
await MapArrayAsync(
MapArray(
httpResponseHeaders.TransferEncoding,
MapToTransferCodingHeader),

TransferEncodingChunked =
httpResponseHeaders.TransferEncodingChunked,

Upgrade =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Upgrade,
MapToProductHeader),

Vary =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Vary,
@string => @string),

Via =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Via,
MapToViaHeader),

Warning =
await MapArrayAsync(
MapArray(
httpResponseHeaders.Warning,
MapToWarningHeader),

WwwAuthenticate =
await MapArrayAsync(
MapArray(
httpResponseHeaders.WwwAuthenticate,
MapToAuthenticationHeader)
};
}

private static async ValueTask<HttpExchangeContentHeaders> MapHttpExchangeContentHeaders(
private static HttpExchangeContentHeaders MapHttpExchangeContentHeaders(
HttpContentHeaders httpContentHeaders)
{
if (httpContentHeaders is null)
Expand All @@ -364,7 +363,7 @@ private static async ValueTask<HttpExchangeContentHeaders> MapHttpExchangeConten
return new HttpExchangeContentHeaders
{
Allow =
await MapArrayAsync(
MapArray(
httpContentHeaders.Allow,
@string => @string),

Expand All @@ -373,12 +372,12 @@ await MapArrayAsync(
httpContentHeaders.ContentDisposition),

ContentEncoding =
await MapArrayAsync(
MapArray(
httpContentHeaders.ContentEncoding,
@string => @string),

ContentLanguage =
await MapArrayAsync(
MapArray(
httpContentHeaders.ContentLanguage,
@string => @string),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace STX.REST.RESTFulSense.Clients.Services.Foundations.HttpExchanges
{
internal partial class HttpExchangeService
{
private static async ValueTask<TOutput[]> MapArrayAsync<TInput, TOutput>(
private static TOutput[] MapArray<TInput, TOutput>(
IEnumerable<TInput> elements,
Func<TInput, TOutput> functionMapping)
{
Expand Down Expand Up @@ -54,7 +54,7 @@ private static string MapUrlParameters(
return fullRelativeUrl;
}

private static async ValueTask<HttpRequestMessage> MapToHttpRequestAsync(
private static HttpRequestMessage MapToHttpRequest(
HttpExchangeRequest httpExchangeRequest,
HttpMethod defaultHttpMethod,
Version defaultHttpVersion,
Expand All @@ -73,12 +73,12 @@ private static async ValueTask<HttpRequestMessage> MapToHttpRequestAsync(
relativeUrl);

HttpMethod httpMethod =
await GetHttpMethodAsync(
GetHttpMethod(
customHttpMethod: httpExchangeRequest.HttpMethod,
defaultHttpMethod);

Version httpVersion =
await GetHttpVersionAsync(
GetHttpVersion(
customHttpVersion: httpExchangeRequest.Version,
defaultHttpVersion: defaultHttpVersion);

Expand All @@ -103,15 +103,15 @@ await GetHttpVersionAsync(
return httpRequestMessage;
}

private static async ValueTask<HttpExchange> MapToHttpExchange(
private static HttpExchange MapToHttpExchange(
HttpExchange httpExchange,
HttpResponseMessage httpResponseMessage)
{
httpExchange.Response =
new HttpExchangeResponse
{
Headers =
await MapHttpExchangeResponseHeaders(
MapHttpExchangeResponseHeaders(
httpResponseMessage.Headers),

Content =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ await ValidateOnGetAsync(
defaultHttpVersionPolicy);
HttpRequestMessage httpRequestMessage =
await MapToHttpRequestAsync(
MapToHttpRequest(
httpExchangeRequest: httpExchange.Request,
defaultHttpMethod: defaultHttpMethod,
defaultHttpVersion: defaultHttpVersion,
Expand All @@ -50,12 +50,12 @@ await httpBroker.SendRequestAsync(
httpRequestMessage: httpRequestMessage,
cancellationToken: cancellationToken);
return await MapToHttpExchange(
return MapToHttpExchange(
httpExchange,
httpResponseMessage);
});

private static async ValueTask<HttpMethod> GetHttpMethodAsync(
private static HttpMethod GetHttpMethod(
string customHttpMethod,
HttpMethod defaultHttpMethod)
{
Expand All @@ -67,7 +67,7 @@ private static async ValueTask<HttpMethod> GetHttpMethodAsync(
return HttpMethod.Parse(customHttpMethod);
}

private static async ValueTask<Version> GetHttpVersionAsync(
private static Version GetHttpVersion(
string customHttpVersion,
Version defaultHttpVersion)
{
Expand Down

0 comments on commit 2a8ad28

Please sign in to comment.