Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Feb 28, 2025
2 parents c706d91 + 8443b16 commit ccad6c6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -929,24 +929,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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion;
Expand Down Expand Up @@ -1199,17 +1200,12 @@ public ServletInputStream getInputStream() throws IOException
{
if (_inputState != ServletContextRequest.INPUT_NONE && _inputState != ServletContextRequest.INPUT_STREAM)
throw new IllegalStateException("READER");
_inputState = ServletContextRequest.INPUT_STREAM;
try
{
// Try to write a 100 continue, ignoring failure result if it was not necessary.

// Try to write a 100 continue if it is necessary
if (_inputState == ServletContextRequest.INPUT_NONE && _servletContextRequest.getHeaders().contains(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE.asString()))
_servletChannel.getResponse().writeInterim(HttpStatus.CONTINUE_100, HttpFields.EMPTY);
}
catch (IllegalStateException ise)
{
if (LOG.isTraceEnabled())
LOG.trace("IGNORED", ise);
}

_inputState = ServletContextRequest.INPUT_STREAM;
return getServletRequestInfo().getHttpInput();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.HttpVersion;
Expand Down Expand Up @@ -1208,17 +1209,12 @@ public ServletInputStream getInputStream() throws IOException
{
if (_inputState != ServletContextRequest.INPUT_NONE && _inputState != ServletContextRequest.INPUT_STREAM)
throw new IllegalStateException("READER");
_inputState = ServletContextRequest.INPUT_STREAM;
try
{
// Try to write a 100 continue, ignoring failure result if it was not necessary.

// Try to write a 100 continue if it is necessary
if (_inputState == ServletContextRequest.INPUT_NONE && _servletContextRequest.getHeaders().contains(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE.asString()))
_servletChannel.getResponse().writeInterim(HttpStatus.CONTINUE_100, HttpFields.EMPTY);
}
catch (IllegalStateException ise)
{
if (LOG.isTraceEnabled())
LOG.trace("IGNORED", ise);
}

_inputState = ServletContextRequest.INPUT_STREAM;
return getServletRequestInfo().getHttpInput();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,12 @@ public ServletInputStream getInputStream() throws IOException
{
if (_inputState != INPUT_NONE && _inputState != INPUT_STREAM)
throw new IllegalStateException("READER");

// Try to write a 100 continue if it is necessary.
if (_inputState == INPUT_NONE && _coreRequest.getHeaders().contains(HttpHeader.EXPECT, HttpHeaderValue.CONTINUE.asString()))
_channel.getCoreResponse().writeInterim(HttpStatus.CONTINUE_100, HttpFields.EMPTY);

_inputState = INPUT_STREAM;
// Try to write a 100 continue, ignoring failure result if it was not necessary.
_channel.getCoreResponse().writeInterim(HttpStatus.CONTINUE_100, HttpFields.EMPTY);
return _input;
}

Expand Down

0 comments on commit ccad6c6

Please sign in to comment.