diff --git a/java/org/apache/coyote/http2/Stream.java b/java/org/apache/coyote/http2/Stream.java index 6893955b05bc..2dcf3a86c4d7 100644 --- a/java/org/apache/coyote/http2/Stream.java +++ b/java/org/apache/coyote/http2/Stream.java @@ -552,7 +552,7 @@ public final void emitHeader(String name, String value) throws HpackException { break; } default: { - if ("expect".equals(name) && "100-continue".equals(value)) { + if ("expect".equals(name) && "100-continue".equalsIgnoreCase(value)) { coyoteRequest.setExpectation(true); } if (pseudoHeader) { diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java index 42a8d4e18ec3..48d2b596f109 100644 --- a/test/org/apache/coyote/http2/Http2TestBase.java +++ b/test/org/apache/coyote/http2/Http2TestBase.java @@ -383,6 +383,13 @@ protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPay protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload, boolean useExpectation, String contentType, long contentLength, String path, byte[] dataFrameHeader, ByteBuffer dataPayload, byte[] padding, boolean withTrailers, int streamId) { + buildPostRequest(headersFrameHeader, headersPayload, useExpectation ? "100-continue" : null, contentType, + contentLength, path, dataFrameHeader, dataPayload, padding, withTrailers, streamId); + } + + protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload, String expectation, + String contentType, long contentLength, String path, byte[] dataFrameHeader, ByteBuffer dataPayload, + byte[] padding, boolean withTrailers, int streamId) { MimeHeaders headers = new MimeHeaders(); headers.addValue(":method").setString(Method.POST); @@ -393,8 +400,8 @@ protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPay } headers.addValue(":path").setString(path); headers.addValue(":authority").setString("localhost:" + getPort()); - if (useExpectation) { - headers.addValue("expect").setString("100-continue"); + if (expectation != null) { + headers.addValue("expect").setString(expectation); } if (contentType != null) { headers.addValue("content-type").setString(contentType); diff --git a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java index 55cda91103ef..7835e8fe1dbd 100644 --- a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java +++ b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java @@ -152,6 +152,18 @@ public void setContinueHandlingResponsePolicy(ContinueResponseTiming policy) thr @Test public void testSendAck() throws Exception { + doTestSendAck("100-continue"); + } + + + @Test + public void testSendAckMixedCase() throws Exception { + // RFC 9110, section 10.1.1: the Expect field value is case-insensitive + doTestSendAck("100-Continue"); + } + + + private void doTestSendAck(String expectation) throws Exception { // makes a request that expects a 100 Continue response and verifies // that the 100 Continue response is received. This does not check // that the correct ContinueHandlingResponsePolicy was followed, just @@ -167,8 +179,8 @@ public void testSendAck() throws Exception { byte[] dataFrameHeader = new byte[9]; ByteBuffer dataPayload = ByteBuffer.allocate(256); - buildPostRequest(headersFrameHeader, headersPayload, true, null, -1, "/simple", dataFrameHeader, dataPayload, - null, false, 3); + buildPostRequest(headersFrameHeader, headersPayload, expectation, null, -1, "/simple", dataFrameHeader, + dataPayload, null, false, 3); // Write the headers writeFrame(headersFrameHeader, headersPayload); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 40cee9a06286..fac3d12573bb 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -370,6 +370,13 @@ that is in asynchronous mode are released if the connection thread raises a stream error for that stream. (markt) + + Treat the value of the Expect header as case insensitive + for HTTP/2 requests, as required by RFC 9110, section 10.1.1, so that a + 100 (Continue) response is sent for + Expect: 100-Continue. Pull request 1263 provided + by Arturo Bernal. +