This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new d8aae21 Fix broken HTTP/2 push d8aae21 is described below commit d8aae2192af76b2aab88be502b92310b065f4022 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 95c2101..3b14bb6 100644 --- a/java/org/apache/coyote/http2/Stream.java +++ b/java/org/apache/coyote/http2/Stream.java @@ -58,6 +58,8 @@ 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); @@ -100,21 +102,23 @@ 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 86830b0..c831843 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -119,6 +119,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-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org