@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2017 the original author or authors .
* Copyright 2002 - 2018 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -38,6 +38,7 @@ import reactor.core.publisher.Flux;
@@ -38,6 +38,7 @@ import reactor.core.publisher.Flux;
import org.springframework.core.io.buffer.DataBuffer ;
import org.springframework.core.io.buffer.DataBufferFactory ;
import org.springframework.core.io.buffer.DefaultDataBufferFactory ;
import org.springframework.http.HttpCookie ;
import org.springframework.http.HttpHeaders ;
import org.springframework.http.MediaType ;
@ -60,6 +61,8 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
@@ -60,6 +61,8 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
private static final String SSL_SESSION_ID_ATTRIBUTE = "javax.servlet.request.ssl_session_id" ;
static final DataBuffer EOF_BUFFER = new DefaultDataBufferFactory ( ) . allocateBuffer ( 0 ) ;
protected final Log logger = LogFactory . getLog ( getClass ( ) ) ;
@ -197,7 +200,7 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
@@ -197,7 +200,7 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
* Invoked only when { @link ServletInputStream # isReady ( ) } returns "true" .
* /
@Nullable
protected DataBuffer readFromInputStream ( ) throws IOException {
DataBuffer readFromInputStream ( ) throws IOException {
int read = this . request . getInputStream ( ) . read ( this . buffer ) ;
if ( logger . isTraceEnabled ( ) ) {
logger . trace ( "InputStream read returned " + read + ( read ! = - 1 ? " bytes" : "" ) ) ;
@ -208,6 +211,9 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
@@ -208,6 +211,9 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
dataBuffer . write ( this . buffer , 0 , read ) ;
return dataBuffer ;
}
else if ( read = = - 1 ) {
return EOF_BUFFER ;
}
return null ;
}
@ -266,7 +272,14 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
@@ -266,7 +272,14 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
@Nullable
protected DataBuffer read ( ) throws IOException {
if ( this . inputStream . isReady ( ) ) {
return readFromInputStream ( ) ;
DataBuffer dataBuffer = readFromInputStream ( ) ;
if ( dataBuffer ! = EOF_BUFFER ) {
return dataBuffer ;
}
else {
// No need to wait for container callback...
onAllDataRead ( ) ;
}
}
return null ;
}