You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/03/07 10:36:09 UTC
[tomcat] branch 8.5.x updated: Fix broken HTTP/2 push
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 4938ddc Fix broken HTTP/2 push
4938ddc is described below
commit 4938ddc6be047ed7e020f2f51bd6c99da650d896
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 7 10:34:00 2019 +0000
Fix broken HTTP/2 push
---
java/org/apache/coyote/http2/Stream.java | 26 +++++++++++++++-----------
webapps/docs/changelog.xml | 4 ++++
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java
index 35d066a..2c9021e 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -55,6 +55,8 @@ public class Stream extends AbstractStream implements HeaderEmitter {
private static final MimeHeaders ACK_HEADERS;
+ private static final Integer HTTP_UPGRADE_STREAM = Integer.valueOf(1);
+
static {
Response response = new Response();
response.setStatus(100);
@@ -97,21 +99,23 @@ public class Stream extends AbstractStream implements HeaderEmitter {
this.inputBuffer = new StreamInputBuffer();
this.coyoteRequest.setInputBuffer(inputBuffer);
} else {
- // HTTP/1.1 upgrade
+ // HTTP/2 Push or HTTP/1.1 upgrade
this.coyoteRequest = coyoteRequest;
this.inputBuffer = null;
// Headers have been read by this point
state.receivedStartOfHeaders();
- // Populate coyoteRequest from headers
- try {
- prepareRequest();
- } catch (IllegalArgumentException iae) {
- // Something in the headers is invalid
- // Set correct return status
- coyoteResponse.setStatus(400);
- // Set error flag. This triggers error processing rather than
- // the normal mapping
- coyoteResponse.setError();
+ if (HTTP_UPGRADE_STREAM.equals(identifier)) {
+ // Populate coyoteRequest from headers (HTTP/1.1 only)
+ try {
+ prepareRequest();
+ } catch (IllegalArgumentException iae) {
+ // Something in the headers is invalid
+ // Set correct return status
+ coyoteResponse.setStatus(400);
+ // Set error flag. This triggers error processing rather than
+ // the normal mapping
+ coyoteResponse.setError();
+ }
}
// TODO Assuming the body has been read at this point is not valid
state.receivedEndOfStream();
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 90297df..64b2d07 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,6 +160,10 @@
NIO2 should try to use SocketTimeoutException everywhere rather than a
mix of it and InterruptedByTimeout. (remm)
</fix>
+ <fix>
+ Correct an error in the request validation that meant that HTTP/2 push
+ requests always resulted in a 400 response. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="WebSocket">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org