Skip to content

Commit 8da7440

Browse files
swankjesseyschimke
andauthored
Remove renumbering indirection in settings frames (#8385)
This makes the code difficult to understand. Co-authored-by: Jesse Wilson <[email protected]> Co-authored-by: Yuri Schimke <[email protected]>
1 parent 61ab31a commit 8da7440

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

okhttp/src/main/kotlin/okhttp3/internal/http2/Http2Reader.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class Http2Reader(
261261
if (length % 6 != 0) throw IOException("TYPE_SETTINGS length % 6 != 0: $length")
262262
val settings = Settings()
263263
for (i in 0 until length step 6) {
264-
var id = source.readShort() and 0xffff
264+
val id = source.readShort() and 0xffff
265265
val value = source.readInt()
266266

267267
when (id) {
@@ -277,11 +277,11 @@ class Http2Reader(
277277
}
278278

279279
// SETTINGS_MAX_CONCURRENT_STREAMS
280-
3 -> id = 4 // Renumbered in draft 10.
280+
3 -> {
281+
}
281282

282283
// SETTINGS_INITIAL_WINDOW_SIZE
283284
4 -> {
284-
id = 7 // Renumbered in draft 10.
285285
if (value < 0) {
286286
throw IOException("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1")
287287
}

okhttp/src/main/kotlin/okhttp3/internal/http2/Http2Writer.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,7 @@ class Http2Writer(
209209
)
210210
for (i in 0 until Settings.COUNT) {
211211
if (!settings.isSet(i)) continue
212-
val id =
213-
when (i) {
214-
4 -> 3 // SETTINGS_MAX_CONCURRENT_STREAMS renumbered.
215-
7 -> 4 // SETTINGS_INITIAL_WINDOW_SIZE renumbered.
216-
else -> i
217-
}
218-
sink.writeShort(id)
212+
sink.writeShort(i)
219213
sink.writeInt(settings[i])
220214
}
221215
sink.flush()

okhttp/src/main/kotlin/okhttp3/internal/http2/Settings.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ class Settings {
116116
const val ENABLE_PUSH = 2
117117

118118
/** Sender's maximum number of concurrent streams. */
119-
const val MAX_CONCURRENT_STREAMS = 4
119+
const val MAX_CONCURRENT_STREAMS = 3
120+
121+
/** Window size in bytes. */
122+
const val INITIAL_WINDOW_SIZE = 4
120123

121124
/** HTTP/2: Size in bytes of the largest frame payload the sender will accept. */
122125
const val MAX_FRAME_SIZE = 5
123126

124127
/** HTTP/2: Advisory only. Size in bytes of the largest header list the sender will accept. */
125128
const val MAX_HEADER_LIST_SIZE = 6
126129

127-
/** Window size in bytes. */
128-
const val INITIAL_WINDOW_SIZE = 7
129-
130130
/** Total number of settings. */
131131
const val COUNT = 10
132132
}

0 commit comments

Comments
 (0)