From 82fd7bf81698b93435596771a754ea9c8595c009 Mon Sep 17 00:00:00 2001 From: Eric Cochran Date: Fri, 29 Jan 2016 13:27:25 -0800 Subject: [PATCH] Fix throwing with HTTP2 unknown settings frame id --- .../java/okhttp3/internal/framed/Http2Test.java | 13 ++++++------- .../main/java/okhttp3/internal/framed/Http2.java | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/okhttp-tests/src/test/java/okhttp3/internal/framed/Http2Test.java b/okhttp-tests/src/test/java/okhttp3/internal/framed/Http2Test.java index bbe771ff8268..9ee52d95e0de 100644 --- a/okhttp-tests/src/test/java/okhttp3/internal/framed/Http2Test.java +++ b/okhttp-tests/src/test/java/okhttp3/internal/framed/Http2Test.java @@ -268,7 +268,7 @@ public void pushPromise(int streamId, int promisedStreamId, List
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); @@ -276,12 +276,11 @@ public void pushPromise(int streamId, int promisedStreamId, List
headerB 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 { diff --git a/okhttp/src/main/java/okhttp3/internal/framed/Http2.java b/okhttp/src/main/java/okhttp3/internal/framed/Http2.java index 78ca9ce79976..a6c177cc608b 100644 --- a/okhttp/src/main/java/okhttp3/internal/framed/Http2.java +++ b/okhttp/src/main/java/okhttp3/internal/framed/Http2.java @@ -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); }