Skip to content

Commit

Permalink
Simplify the code and fix an edge case for BZ 64830
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jan 14, 2021
1 parent 5961f65 commit bb0e7c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions java/org/apache/coyote/AbstractProtocol.java
Expand Up @@ -833,8 +833,10 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
if (state == SocketState.UPGRADING) {
// Get the HTTP upgrade handler
UpgradeToken upgradeToken = processor.getUpgradeToken();
// Retrieve leftover input
// Restore leftover input to the wrapper so the upgrade
// processor can process it.
ByteBuffer leftOverInput = processor.getLeftoverInput();
wrapper.unRead(leftOverInput);
if (upgradeToken == null) {
// Assume direct HTTP/2 connection
UpgradeProtocol upgradeProtocol = getProtocol().getUpgradeProtocol("h2c");
Expand All @@ -843,7 +845,6 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
release(processor);
// Create the upgrade processor
processor = upgradeProtocol.getProcessor(wrapper, getProtocol().getAdapter());
wrapper.unRead(leftOverInput);
// Associate with the processor with the connection
connections.put(socket, processor);
} else {
Expand All @@ -865,7 +866,6 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
getLog().debug(sm.getString("abstractConnectionHandler.upgradeCreate",
processor, wrapper));
}
wrapper.unRead(leftOverInput);
// Associate with the processor with the connection
connections.put(socket, processor);
// Initialise the upgrade handler (which may trigger
Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Expand Up @@ -162,6 +162,10 @@
</subsection>
<subsection name="Coyote">
<changelog>
<fix>
Additional fix for <bug>64830</bug> to address an edge case that could
trigger request corruption with h2c connections. (markt)
</fix>
<fix>
<bug>64974</bug>: Improve handling of pipelined HTTP requests in
combination with the Servlet non-blocking IO API. It was possible that
Expand Down

0 comments on commit bb0e7c1

Please sign in to comment.