Skip to content

Commit

Permalink
Fix NativeArrayContent
Browse files Browse the repository at this point in the history
  • Loading branch information
kochounoyume committed Jan 1, 2025
1 parent 221ca9b commit 062d6e3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Packages/MinimalUtility/Runtime/WebRequest/NativeArrayContent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
#if ENABLE_WEBREQUEST && ENABLE_UNITASK
#nullable enable

using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Unity.Collections;

namespace MinimalUtility.WebRequest
Expand All @@ -21,10 +25,12 @@ public NativeArrayContent(NativeArray<byte>.ReadOnly data, IDisposable handler)
_handler = handler;
}

protected override Task SerializeToStreamAsync(Stream stream, TransportContext _)
protected override async Task SerializeToStreamAsync(Stream stream, TransportContext _)
{
stream.Write(_data.AsReadOnlySpan());
return Task.CompletedTask;
await using (UniTask.ReturnToMainThread())
{
stream.Write(_data.AsReadOnlySpan());
}
}

protected override bool TryComputeLength(out long length)
Expand All @@ -42,4 +48,5 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}
}
}
}
#endif

0 comments on commit 062d6e3

Please sign in to comment.