Skip to content

Commit d0272ef

Browse files
committed
okhttp: update HpackTest to verify unindexed pseudo header :method PUT (grpc#12819)
1 parent 7a9a28c commit d0272ef

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

  • okhttp/third_party/okhttp/test/java/io/grpc/okhttp/internal/framed

okhttp/third_party/okhttp/test/java/io/grpc/okhttp/internal/framed/HpackTest.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,12 @@ public void readerEviction() throws IOException {
274274
* http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-12#appendix-C.2.2
275275
*/
276276
@Test public void literalHeaderFieldWithoutIndexingIndexedName() throws IOException {
277-
List<Header> headerBlock = headerEntries(":path", "/sample/path");
277+
List<Header> headerBlock = headerEntries(":method", "PUT");
278278

279-
bytesIn.writeByte(0x04); // == Literal not indexed ==
280-
// Indexed name (idx = 4) -> :path
281-
bytesIn.writeByte(0x0c); // Literal value (len = 12)
282-
bytesIn.writeUtf8("/sample/path");
279+
bytesIn.writeByte(0x02); // == Literal not indexed ==
280+
// Indexed name (idx = 2) -> :method
281+
bytesIn.writeByte(0x03); // Literal value (len = 3)
282+
bytesIn.writeUtf8("PUT");
283283

284284
hpackWriter.writeHeaders(headerBlock);
285285
assertEquals(bytesIn, bytesOut);
@@ -1129,6 +1129,15 @@ public void pseudoHeaderIndexingForPathAndAuthority() throws IOException {
11291129
hpackWriter.writeHeaders(headerEntries(":authority", "foo.com"));
11301130
assertBytes(0xbe);
11311131
assertEquals(2, hpackWriter.dynamicTableHeaderCount);
1132+
1133+
// If the :authority header value changes, it should be added as a new dynamic table entry.
1134+
hpackWriter.writeHeaders(headerEntries(":authority", "bar.com"));
1135+
assertBytes(0x41, 7, 'b', 'a', 'r', '.', 'c', 'o', 'm');
1136+
assertEquals(3, hpackWriter.dynamicTableHeaderCount);
1137+
1138+
hpackWriter.writeHeaders(headerEntries(":authority", "bar.com"));
1139+
assertBytes(0xbe);
1140+
assertEquals(3, hpackWriter.dynamicTableHeaderCount);
11321141
}
11331142

11341143
@Test
@@ -1140,17 +1149,6 @@ public void evictToRecoverBytesDoesNotNpeWhenBytesToRecoverExceedsTable() throws
11401149
hpackWriter.resizeHeaderTable(0);
11411150

11421151
assertEquals(0, hpackWriter.dynamicTableHeaderCount);
1143-
assertEquals(0, hpackWriter.dynamicTableByteCount);
1144-
}
1145-
1146-
// If the :authority header somehow changes, it should be re-added to the dynamic table.
1147-
hpackWriter.writeHeaders(headerEntries(":authority", "bar.com"));
1148-
assertBytes(0x41, 7, 'b', 'a', 'r', '.', 'c', 'o', 'm');
1149-
assertEquals(2, hpackWriter.dynamicTableHeaderCount);
1150-
1151-
hpackWriter.writeHeaders(headerEntries(":authority", "bar.com"));
1152-
assertBytes(0xbe);
1153-
assertEquals(2, hpackWriter.dynamicTableHeaderCount);
11541152
}
11551153

11561154
@Test

0 commit comments

Comments
 (0)