aboutsummaryrefslogtreecommitdiff
path: root/lib/Net.Http/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Net.Http/src')
-rw-r--r--lib/Net.Http/src/Core/Buffering/ContextLockedBufferManager.cs13
-rw-r--r--lib/Net.Http/src/Core/HttpContext.cs13
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/Net.Http/src/Core/Buffering/ContextLockedBufferManager.cs b/lib/Net.Http/src/Core/Buffering/ContextLockedBufferManager.cs
index b99e3ff..b11b62b 100644
--- a/lib/Net.Http/src/Core/Buffering/ContextLockedBufferManager.cs
+++ b/lib/Net.Http/src/Core/Buffering/ContextLockedBufferManager.cs
@@ -145,6 +145,19 @@ namespace VNLib.Net.Http.Core.Buffering
///<inheritdoc/>
public IChunkAccumulatorBuffer ChunkAccumulatorBuffer => _chunkAccBuffer;
+ public Memory<byte> GetInitStreamBuffer()
+ {
+ /*
+ * Since this buffer must be shared with char buffers, size
+ * must be respected. Remember that split buffesr store binary
+ * data at the head of the buffer and char data at the tail
+ */
+
+ Memory<byte> dataBuffer = RequestHeaderParseBuffer.GetMemory();
+
+ return dataBuffer[..RequestHeaderParseBuffer.BinSize];
+ }
+
/*
* Response buffer and form data buffer are shared because they are never
diff --git a/lib/Net.Http/src/Core/HttpContext.cs b/lib/Net.Http/src/Core/HttpContext.cs
index 18aef69..aa6f260 100644
--- a/lib/Net.Http/src/Core/HttpContext.cs
+++ b/lib/Net.Http/src/Core/HttpContext.cs
@@ -172,7 +172,7 @@ namespace VNLib.Net.Http.Core
{
/*
* This function allows for pre-buffering of the transport
- * before parsing the response. It also allows waiting for more data async
+ * before parsing the request. It also allows waiting for more data async
* when an http1 request is in keep-alive mode waiting for more data.
*
* We can asynchronously read data when its available and preload
@@ -185,18 +185,11 @@ namespace VNLib.Net.Http.Core
_bytesRead = 0;
- Memory<byte> dataBuffer = Buffers.RequestHeaderParseBuffer.GetMemory();
-
- /*
- * Since this buffer must be shared with char buffers, size
- * must be respected. Remember that split buffesr store binary
- * data at the head of the buffer and char data at the tail
- */
- dataBuffer = dataBuffer[..Buffers.RequestHeaderParseBuffer.BinSize];
+ Memory<byte> dataBuffer = Buffers.GetInitStreamBuffer();
_bytesRead = await _ctx!.ConnectionStream.ReadAsync(dataBuffer, cancellation);
- Debug.Assert(_bytesRead <= Buffers.RequestHeaderParseBuffer.BinSize);
+ Debug.Assert(_bytesRead <= dataBuffer.Length);
}
#endregion