Skip to content

Commit

Permalink
Fix throwing with HTTP2 unknown settings frame id
Browse files Browse the repository at this point in the history
  • Loading branch information
NightlyNexus committed Jan 29, 2016
1 parent 38ddfed commit 82fd7bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,19 @@ public void pushPromise(int streamId, int promisedStreamId, List<Header> headerB
}
}

@Test public void readSettingsFrameInvalidSettingId() throws IOException {
@Test public void readSettingsFrameUnknownSettingId() throws IOException {
writeMedium(frame, 6); // 2 for the code and 4 for the value
frame.writeByte(Http2.TYPE_SETTINGS);
frame.writeByte(Http2.FLAG_NONE);
frame.writeInt(0); // Settings are always on the connection stream 0.
frame.writeShort(7); // old number for SETTINGS_INITIAL_WINDOW_SIZE
frame.writeInt(1);

try {
fr.nextFrame(new BaseTestHandler());
fail();
} catch (IOException e) {
assertEquals("PROTOCOL_ERROR invalid settings id: 7", e.getMessage());
}
fr.nextFrame(new BaseTestHandler() {
@Override public void settings(boolean clearPrevious, Settings settings) {
assert settings.get(7) == 1;
}
});
}

@Test public void readSettingsFrameNegativeWindowSize() throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion okhttp/src/main/java/okhttp3/internal/framed/Http2.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private void readSettings(Handler handler, int length, byte flags, int streamId)
case 6: // SETTINGS_MAX_HEADER_LIST_SIZE
break; // Advisory only, so ignored.
default:
throw ioException("PROTOCOL_ERROR invalid settings id: %s", id);
break; // Must ignore setting with unknown id.
}
settings.set(id, 0, value);
}
Expand Down

0 comments on commit 82fd7bf

Please sign in to comment.