Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove renumbering indirection in settings frames #8385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions okhttp/src/main/kotlin/okhttp3/internal/http2/Http2Reader.kt
Expand Up @@ -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) {
Expand All @@ -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")
}
Expand Down
8 changes: 1 addition & 7 deletions okhttp/src/main/kotlin/okhttp3/internal/http2/Http2Writer.kt
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions okhttp/src/main/kotlin/okhttp3/internal/http2/Settings.kt
Expand Up @@ -116,17 +116,17 @@ 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

/** 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
}
Expand Down