Removed reliance on exception to shutdown non persistent connections (#12213)
Moved the shutdownOutput in HttpStreamOverHttp1 to before the continuation of handling
This commit is contained in:
parent
1726c8778c
commit
ebc5e559f8
|
@ -371,11 +371,11 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
||||||
{
|
{
|
||||||
while (getEndPoint().isOpen())
|
while (getEndPoint().isOpen())
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("onFillable fill and parse {} {} {}", this, _httpChannel, _retainableByteBuffer);
|
|
||||||
|
|
||||||
// Fill the request buffer (if needed).
|
// Fill the request buffer (if needed).
|
||||||
int filled = fillRequestBuffer();
|
int filled = fillRequestBuffer();
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("onFillable filled {} {} {} {}", filled, this, _httpChannel, _retainableByteBuffer);
|
||||||
|
|
||||||
if (filled < 0 && getEndPoint().isOutputShutdown())
|
if (filled < 0 && getEndPoint().isOutputShutdown())
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
@ -1523,12 +1523,17 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As this is not an upgrade, we can shutdown the output if we know we are not persistent
|
||||||
|
if (_sendCallback._shutdownOut)
|
||||||
|
getEndPoint().shutdownOutput();
|
||||||
|
|
||||||
_httpChannel.recycle();
|
_httpChannel.recycle();
|
||||||
|
|
||||||
|
|
||||||
|
// If a 100 Continue is still expected to be sent, but no content was read, then
|
||||||
|
// close the parser so that seeks EOF below, not the next request.
|
||||||
if (_expects100Continue)
|
if (_expects100Continue)
|
||||||
{
|
{
|
||||||
// No content was read, and no 100 Continue response was sent.
|
|
||||||
// Close the parser so that below it seeks EOF, not the next request.
|
|
||||||
_expects100Continue = false;
|
_expects100Continue = false;
|
||||||
_parser.close();
|
_parser.close();
|
||||||
}
|
}
|
||||||
|
@ -1541,7 +1546,6 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
||||||
else
|
else
|
||||||
_parser.close();
|
_parser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
_generator.reset();
|
_generator.reset();
|
||||||
|
|
||||||
// Can the onFillable thread continue processing
|
// Can the onFillable thread continue processing
|
||||||
|
@ -1552,9 +1556,6 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("non-current completion {}", this);
|
LOG.debug("non-current completion {}", this);
|
||||||
|
|
||||||
if (_sendCallback._shutdownOut)
|
|
||||||
getEndPoint().shutdownOutput();
|
|
||||||
|
|
||||||
// If we are looking for the next request
|
// If we are looking for the next request
|
||||||
if (_parser.isStart())
|
if (_parser.isStart())
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,7 +200,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
try (StacklessLogging ignored = new StacklessLogging(Response.class); Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
try (StacklessLogging ignored = new StacklessLogging(Response.class); Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
|
@ -1669,12 +1669,10 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
||||||
|
|
||||||
String line = in.readLine();
|
String line = in.readLine();
|
||||||
System.err.println(line);
|
|
||||||
assertThat(line, containsString(" 304 "));
|
assertThat(line, containsString(" 304 "));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
line = in.readLine();
|
line = in.readLine();
|
||||||
System.err.println(line);
|
|
||||||
if (line == null)
|
if (line == null)
|
||||||
throw new EOFException();
|
throw new EOFException();
|
||||||
if (line.length() == 0)
|
if (line.length() == 0)
|
||||||
|
@ -1685,7 +1683,6 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
assertThat(line, not(containsString("Transfer-Encoding")));
|
assertThat(line, not(containsString("Transfer-Encoding")));
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println("---");
|
|
||||||
line = in.readLine();
|
line = in.readLine();
|
||||||
assertThat(line, containsString(" 304 "));
|
assertThat(line, containsString(" 304 "));
|
||||||
while (true)
|
while (true)
|
||||||
|
|
Loading…
Reference in New Issue