ikyriak / IdempotentAPI

A .NET library that handles the HTTP write operations (POST and PATCH) that can affect only once for the given request data and idempotency-key by using an ASP.NET Core attribute (filter).
MIT License
270 stars 39 forks source link

Request data hash always returns empty byte array #58

Closed vaspopinex closed 9 months ago

vaspopinex commented 1 year ago

The following code in the GetRequestsDataHash method doesnt seem to work as expected. In our scenarios we keep getting the result always being a byte[0]. Which thus results in the unwanted behaviour of requests with different payloads and same idempotency key are treated as the same.

httpRequest.EnableBuffering();

if (httpRequest.Body.CanRead
    && httpRequest.Body.CanSeek)
{
    using MemoryStream memoryStream = new();
    httpRequest.Body.Position = 0;

    await httpRequest.Body.CopyToAsync(memoryStream).ConfigureAwait(false);
    requestsData.Add(memoryStream.ToArray());
ikyriak commented 1 year ago

Hello @vaspopinex

Thank you for reporting this issue 🙏 I will fix it as soon as possible.

ikyriak commented 1 year ago

Hello @vaspopinex

I have prepared the following pre-release packages to fix this issue. When you have time, could you please check that it is fixed in your use-case?