Skip to content

Commit 583c74d

Browse files
committed
Require an authority for HTTP/2 requests
1 parent 70d0d45 commit 583c74d

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

java/org/apache/coyote/http2/Stream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ final boolean receivedEndOfHeaders() throws StreamException {
602602
}
603603
} else {
604604
// All other methods
605-
if (coyoteRequest.scheme().isNull() || coyoteRequest.requestURI().isNull()) {
605+
if (coyoteRequest.scheme().isNull() || coyoteRequest.requestURI().isNull() ||
606+
coyoteRequest.serverName().isNull()) {
606607
missingHeader = true;
607608
}
608609
}

test/org/apache/coyote/http2/TestHttp2Section_8_1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void testHostHeaderInvalid() throws Exception {
301301
parser.readFrame();
302302

303303
String trace = output.getTrace();
304-
Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[400]"));
304+
Assert.assertTrue(trace, trace.contains("3-RST-[1]"));
305305
}
306306

307307

@@ -325,7 +325,7 @@ public void testAuthorityHeaderInvalid() throws Exception {
325325
parser.readFrame();
326326

327327
String trace = output.getTrace();
328-
Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[400]"));
328+
Assert.assertTrue(trace, trace.contains("3-RST-[1]"));
329329
}
330330

331331

webapps/docs/changelog.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@
313313
When processing an HTTP upgrade from HTTP/1.1 to HTTP/2, ensure that all
314314
the HTTP/1.1 data has been processed before switching protocols. (markt)
315315
</fix>
316+
<fix>
317+
Require every HTTP/2 request to provide an authority (either an
318+
<code>:authority</code> pseudo header or a <code>Host</code> header).
319+
(markt)
320+
</fix>
316321
</changelog>
317322
</subsection>
318323
<subsection name="Jasper">

0 commit comments

Comments
 (0)