Commit 8443b16 1 parent 4d10c20 commit 8443b16 Copy full SHA for 8443b16
File tree 3 files changed +29
-8
lines changed
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal
jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet
jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested
3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -917,24 +917,38 @@ public Content.Chunk read()
917
917
try
918
918
{
919
919
HttpStream stream ;
920
+ boolean expecting100 ;
921
+ HttpChannelState httpChannel ;
920
922
try (AutoLock ignored = _lock .lock ())
921
923
{
922
- HttpChannelState httpChannel = lockedGetHttpChannelState ();
923
-
924
+ httpChannel = lockedGetHttpChannelState ();
924
925
Content .Chunk error = httpChannel ._readFailure ;
925
926
httpChannel ._readFailure = Content .Chunk .next (error );
926
927
if (error != null )
927
928
return error ;
928
929
929
930
stream = httpChannel ._stream ;
931
+ expecting100 = httpChannel ._expects100Continue ;
930
932
}
931
933
Content .Chunk chunk = stream .read ();
932
934
933
935
if (LOG .isDebugEnabled ())
934
936
LOG .debug ("read {}" , chunk );
935
937
936
- if (chunk != null && chunk .hasRemaining ())
937
- _contentBytesRead .add (chunk .getByteBuffer ().remaining ());
938
+ if (chunk == null )
939
+ return null ;
940
+
941
+ if (expecting100 )
942
+ {
943
+ // No need to send 100 continues as content has already arrived
944
+ try (AutoLock ignored = _lock .lock ())
945
+ {
946
+ httpChannel ._expects100Continue = false ;
947
+ }
948
+ }
949
+
950
+ if (chunk .hasRemaining ())
951
+ _contentBytesRead .add (chunk .remaining ());
938
952
939
953
if (chunk instanceof Trailers trailers )
940
954
_trailers = trailers .getTrailers ();
Original file line number Diff line number Diff line change 63
63
import org .eclipse .jetty .http .HttpField ;
64
64
import org .eclipse .jetty .http .HttpFields ;
65
65
import org .eclipse .jetty .http .HttpHeader ;
66
+ import org .eclipse .jetty .http .HttpHeaderValue ;
66
67
import org .eclipse .jetty .http .HttpStatus ;
67
68
import org .eclipse .jetty .http .HttpURI ;
68
69
import org .eclipse .jetty .http .HttpVersion ;
@@ -916,9 +917,12 @@ public ServletInputStream getInputStream() throws IOException
916
917
{
917
918
if (_inputState != ServletContextRequest .INPUT_NONE && _inputState != ServletContextRequest .INPUT_STREAM )
918
919
throw new IllegalStateException ("READER" );
920
+
921
+ // Try to write a 100 continue if it is necessary
922
+ if (_inputState == ServletContextRequest .INPUT_NONE && _servletContextRequest .getHeaders ().contains (HttpHeader .EXPECT , HttpHeaderValue .CONTINUE .asString ()))
923
+ _servletChannel .getResponse ().writeInterim (HttpStatus .CONTINUE_100 , HttpFields .EMPTY );
924
+
919
925
_inputState = ServletContextRequest .INPUT_STREAM ;
920
- // Try to write a 100 continue, ignoring failure result if it was not necessary.
921
- _servletChannel .getResponse ().writeInterim (HttpStatus .CONTINUE_100 , HttpFields .EMPTY );
922
926
return getServletRequestInfo ().getHttpInput ();
923
927
}
924
928
Original file line number Diff line number Diff line change @@ -914,9 +914,12 @@ public ServletInputStream getInputStream() throws IOException
914
914
{
915
915
if (_inputState != INPUT_NONE && _inputState != INPUT_STREAM )
916
916
throw new IllegalStateException ("READER" );
917
+
918
+ // Try to write a 100 continue if it is necessary.
919
+ if (_inputState == INPUT_NONE && _coreRequest .getHeaders ().contains (HttpHeader .EXPECT , HttpHeaderValue .CONTINUE .asString ()))
920
+ _channel .getCoreResponse ().writeInterim (HttpStatus .CONTINUE_100 , HttpFields .EMPTY );
921
+
917
922
_inputState = INPUT_STREAM ;
918
- // Try to write a 100 continue, ignoring failure result if it was not necessary.
919
- _channel .getCoreResponse ().writeInterim (HttpStatus .CONTINUE_100 , HttpFields .EMPTY );
920
923
return _input ;
921
924
}
922
925
You can’t perform that action at this time.
0 commit comments