This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new e529749 Align HTTP/2 code with trunk to simplify back-ports
e529749 is described below
commit e529749c1eeaceaca77fd83e87c522b271ab6311
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Mar 7 11:26:34 2019 +0000
Align HTTP/2 code with trunk to simplify back-ports
---
java/org/apache/coyote/http2/Http2Parser.java | 54 +++++++++++-----------
.../apache/coyote/http2/Http2UpgradeHandler.java | 29 +++++++-----
2 files changed, 44 insertions(+), 39 deletions(-)
diff --git a/java/org/apache/coyote/http2/Http2Parser.java
b/java/org/apache/coyote/http2/Http2Parser.java
index d696cd4..3980094 100644
--- a/java/org/apache/coyote/http2/Http2Parser.java
+++ b/java/org/apache/coyote/http2/Http2Parser.java
@@ -449,33 +449,6 @@ class Http2Parser {
}
- private void onHeadersComplete(int streamId) throws Http2Exception {
- // Any left over data is a compression error
- if (headerReadBuffer.position() > 0) {
- throw new ConnectionException(
-
sm.getString("http2Parser.processFrameHeaders.decodingDataLeft"),
- Http2Error.COMPRESSION_ERROR);
- }
-
- // Delay validation (and triggering any exception) until this point
- // since all the headers still have to be read if a StreamException is
- // going to be thrown.
- hpackDecoder.getHeaderEmitter().validateHeaders();
-
- output.headersEnd(streamId);
-
- if (headersEndStream) {
- output.receivedEndOfStream(streamId);
- headersEndStream = false;
- }
-
- // Reset size for new request if the buffer was previously expanded
- if (headerReadBuffer.capacity() >
Constants.DEFAULT_HEADER_READ_BUFFER_SIZE) {
- headerReadBuffer =
ByteBuffer.allocate(Constants.DEFAULT_HEADER_READ_BUFFER_SIZE);
- }
- }
-
-
private void readUnknownFrame(int streamId, FrameType frameType, int
flags, int payloadSize)
throws IOException {
try {
@@ -518,6 +491,33 @@ class Http2Parser {
}
+ private void onHeadersComplete(int streamId) throws Http2Exception {
+ // Any left over data is a compression error
+ if (headerReadBuffer.position() > 0) {
+ throw new ConnectionException(
+
sm.getString("http2Parser.processFrameHeaders.decodingDataLeft"),
+ Http2Error.COMPRESSION_ERROR);
+ }
+
+ // Delay validation (and triggering any exception) until this point
+ // since all the headers still have to be read if a StreamException is
+ // going to be thrown.
+ hpackDecoder.getHeaderEmitter().validateHeaders();
+
+ output.headersEnd(streamId);
+
+ if (headersEndStream) {
+ output.receivedEndOfStream(streamId);
+ headersEndStream = false;
+ }
+
+ // Reset size for new request if the buffer was previously expanded
+ if (headerReadBuffer.capacity() >
Constants.DEFAULT_HEADER_READ_BUFFER_SIZE) {
+ headerReadBuffer =
ByteBuffer.allocate(Constants.DEFAULT_HEADER_READ_BUFFER_SIZE);
+ }
+ }
+
+
/*
* Implementation note:
* Validation applicable to all incoming frames should be implemented here.
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 6f3287e..6e266c3 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -242,17 +242,7 @@ public class Http2UpgradeHandler extends AbstractStream
implements InternalHttpU
}
// Send the initial settings frame
- try {
- byte[] settings = localSettings.getSettingsFrameForPending();
- socketWrapper.write(true, settings, 0, settings.length);
- socketWrapper.flush(true);
- } catch (IOException ioe) {
- String msg = sm.getString("upgradeHandler.sendPrefaceFail",
connectionId);
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
- throw new ProtocolException(msg, ioe);
- }
+ writeSettings();
// Make sure the client has sent a valid connection preface before we
// send the response to the original request over HTTP/2.
@@ -527,6 +517,22 @@ public class Http2UpgradeHandler extends AbstractStream
implements InternalHttpU
}
+ private void writeSettings() {
+ // Send the initial settings frame
+ try {
+ byte[] settings = localSettings.getSettingsFrameForPending();
+ socketWrapper.write(true, settings, 0, settings.length);
+ socketWrapper.flush(true);
+ } catch (IOException ioe) {
+ String msg = sm.getString("upgradeHandler.sendPrefaceFail",
connectionId);
+ if (log.isDebugEnabled()) {
+ log.debug(msg);
+ }
+ throw new ProtocolException(msg, ioe);
+ }
+ }
+
+
private void writeGoAwayFrame(int maxStreamId, long errorCode, byte[]
debugMsg)
throws IOException {
byte[] fixedPayload = new byte[8];
@@ -726,7 +732,6 @@ public class Http2UpgradeHandler extends AbstractStream
implements InternalHttpU
synchronized (socketWrapper) {
if (socketWrapper.flush(false)) {
socketWrapper.registerWriteInterest();
- return;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]