mirror of
https://github.com/square/okhttp.git
synced 2026-01-12 10:23:16 +03:00
Remove renumbering indirection in settings frames (#8385)
This makes the code difficult to understand. Co-authored-by: Jesse Wilson <jwilson@squareup.com> Co-authored-by: Yuri Schimke <yuri@schimke.ee>
This commit is contained in:
@@ -261,7 +261,7 @@ class Http2Reader(
|
||||
if (length % 6 != 0) throw IOException("TYPE_SETTINGS length % 6 != 0: $length")
|
||||
val settings = Settings()
|
||||
for (i in 0 until length step 6) {
|
||||
var id = source.readShort() and 0xffff
|
||||
val id = source.readShort() and 0xffff
|
||||
val value = source.readInt()
|
||||
|
||||
when (id) {
|
||||
@@ -277,11 +277,11 @@ class Http2Reader(
|
||||
}
|
||||
|
||||
// SETTINGS_MAX_CONCURRENT_STREAMS
|
||||
3 -> id = 4 // Renumbered in draft 10.
|
||||
3 -> {
|
||||
}
|
||||
|
||||
// SETTINGS_INITIAL_WINDOW_SIZE
|
||||
4 -> {
|
||||
id = 7 // Renumbered in draft 10.
|
||||
if (value < 0) {
|
||||
throw IOException("PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1")
|
||||
}
|
||||
|
||||
@@ -209,13 +209,7 @@ class Http2Writer(
|
||||
)
|
||||
for (i in 0 until Settings.COUNT) {
|
||||
if (!settings.isSet(i)) continue
|
||||
val id =
|
||||
when (i) {
|
||||
4 -> 3 // SETTINGS_MAX_CONCURRENT_STREAMS renumbered.
|
||||
7 -> 4 // SETTINGS_INITIAL_WINDOW_SIZE renumbered.
|
||||
else -> i
|
||||
}
|
||||
sink.writeShort(id)
|
||||
sink.writeShort(i)
|
||||
sink.writeInt(settings[i])
|
||||
}
|
||||
sink.flush()
|
||||
|
||||
@@ -116,7 +116,10 @@ class Settings {
|
||||
const val ENABLE_PUSH = 2
|
||||
|
||||
/** Sender's maximum number of concurrent streams. */
|
||||
const val MAX_CONCURRENT_STREAMS = 4
|
||||
const val MAX_CONCURRENT_STREAMS = 3
|
||||
|
||||
/** Window size in bytes. */
|
||||
const val INITIAL_WINDOW_SIZE = 4
|
||||
|
||||
/** HTTP/2: Size in bytes of the largest frame payload the sender will accept. */
|
||||
const val MAX_FRAME_SIZE = 5
|
||||
@@ -124,9 +127,6 @@ class Settings {
|
||||
/** HTTP/2: Advisory only. Size in bytes of the largest header list the sender will accept. */
|
||||
const val MAX_HEADER_LIST_SIZE = 6
|
||||
|
||||
/** Window size in bytes. */
|
||||
const val INITIAL_WINDOW_SIZE = 7
|
||||
|
||||
/** Total number of settings. */
|
||||
const val COUNT = 10
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user