Skip to content

Commit

Permalink
Include diff from gregw for core HttpChannelState.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbartel committed Feb 13, 2025
1 parent 22bba80 commit 8bfb5f3
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -917,24 +917,38 @@ public Content.Chunk read()
try
{
HttpStream stream;
boolean expecting100;
HttpChannelState httpChannel;
try (AutoLock ignored = _lock.lock())
{
HttpChannelState httpChannel = lockedGetHttpChannelState();

httpChannel = lockedGetHttpChannelState();
Content.Chunk error = httpChannel._readFailure;
httpChannel._readFailure = Content.Chunk.next(error);
if (error != null)
return error;

stream = httpChannel._stream;
expecting100 = httpChannel._expects100Continue;
}
Content.Chunk chunk = stream.read();

if (LOG.isDebugEnabled())
LOG.debug("read {}", chunk);

if (chunk != null && chunk.hasRemaining())
_contentBytesRead.add(chunk.getByteBuffer().remaining());
if (chunk == null)
return null;

if (expecting100)
{
// No need to send 100 continues as content has already arrived
try (AutoLock ignored = _lock.lock())
{
httpChannel._expects100Continue = false;
}
}

if (chunk.hasRemaining())
_contentBytesRead.add(chunk.remaining());

if (chunk instanceof Trailers trailers)
_trailers = trailers.getTrailers();
Expand Down

0 comments on commit 8bfb5f3

Please sign in to comment.