Skip to content

Commit

Permalink
Merge pull request square#5103 from square/jakew/internal/2019-05-23
Browse files Browse the repository at this point in the history
Do not use public trampolines for internal functions
  • Loading branch information
JakeWharton authored May 23, 2019
2 parents 9c19166 + 53cae1f commit 5a344e6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
5 changes: 2 additions & 3 deletions okhttp/src/main/java/okhttp3/Cache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package okhttp3

import okhttp3.internal.EMPTY_HEADERS
import okhttp3.internal.addHeaderLenient
import okhttp3.internal.cache.CacheRequest
import okhttp3.internal.cache.CacheStrategy
import okhttp3.internal.cache.DiskLruCache
Expand Down Expand Up @@ -493,7 +492,7 @@ class Cache internal constructor(
val varyHeadersBuilder = Headers.Builder()
val varyRequestHeaderLineCount = readInt(source)
for (i in 0 until varyRequestHeaderLineCount) {
addHeaderLenient(varyHeadersBuilder, source.readUtf8LineStrict())
varyHeadersBuilder.addLenient(source.readUtf8LineStrict())
}
varyHeaders = varyHeadersBuilder.build()

Expand All @@ -504,7 +503,7 @@ class Cache internal constructor(
val responseHeadersBuilder = Headers.Builder()
val responseHeaderLineCount = readInt(source)
for (i in 0 until responseHeaderLineCount) {
addHeaderLenient(responseHeadersBuilder, source.readUtf8LineStrict())
responseHeadersBuilder.addLenient(source.readUtf8LineStrict())
}
val sendRequestMillisString = responseHeadersBuilder[SENT_MILLIS]
val receivedResponseMillisString = responseHeadersBuilder[RECEIVED_MILLIS]
Expand Down
2 changes: 1 addition & 1 deletion okhttp/src/main/java/okhttp3/internal/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fun decodeHexDigit(c: Char): Int = when (c) {
fun List<Header>.toHeaders(): Headers {
val builder = Headers.Builder()
for ((name, value) in this) {
addHeaderLenient(builder, name.utf8(), value.utf8())
builder.addLenient(name.utf8(), value.utf8())
}
return builder.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import okhttp3.Interceptor
import okhttp3.Protocol
import okhttp3.Response
import okhttp3.internal.EMPTY_RESPONSE
import okhttp3.internal.addHeaderLenient
import okhttp3.internal.closeQuietly
import okhttp3.internal.discard
import okhttp3.internal.http.ExchangeCodec
Expand Down Expand Up @@ -224,14 +223,14 @@ class CacheInterceptor(internal val cache: Cache?) : Interceptor {
if (isContentSpecificHeader(fieldName) ||
!isEndToEnd(fieldName) ||
networkHeaders[fieldName] == null) {
addHeaderLenient(result, fieldName, value)
result.addLenient(fieldName, value)
}
}

for (index in networkHeaders.names().indices) {
val fieldName = networkHeaders.name(index)
if (!isContentSpecificHeader(fieldName) && isEndToEnd(fieldName)) {
addHeaderLenient(result, fieldName, networkHeaders.value(index))
result.addLenient(fieldName, networkHeaders.value(index))
}
}

Expand Down
3 changes: 1 addition & 2 deletions okhttp/src/main/java/okhttp3/internal/cache/CacheStrategy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package okhttp3.internal.cache

import okhttp3.Request
import okhttp3.Response
import okhttp3.internal.addHeaderLenient
import okhttp3.internal.http.HttpDate
import okhttp3.internal.http.StatusLine
import okhttp3.internal.toNonNegativeInt
Expand Down Expand Up @@ -217,7 +216,7 @@ class CacheStrategy internal constructor(
}

val conditionalRequestHeaders = request.headers.newBuilder()
addHeaderLenient(conditionalRequestHeaders, conditionName, conditionValue!!)
conditionalRequestHeaders.addLenient(conditionName, conditionValue!!)

val conditionalRequest = request.newBuilder()
.headers(conditionalRequestHeaders.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import okhttp3.Request
import okhttp3.Response
import okhttp3.internal.EMPTY_HEADERS
import okhttp3.internal.checkOffsetAndCount
import okhttp3.internal.addHeaderLenient
import okhttp3.internal.connection.RealConnection
import okhttp3.internal.discard
import okhttp3.internal.headersContentLength
Expand Down Expand Up @@ -219,7 +218,7 @@ class Http1ExchangeCodec(
// parse the result headers until the first blank line
var line = readHeaderLine()
while (line.isNotEmpty()) {
addHeaderLenient(headers, line)
headers.addLenient(line)
line = readHeaderLine()
}
return headers.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import okhttp3.OkHttpClient
import okhttp3.Protocol
import okhttp3.Request
import okhttp3.Response
import okhttp3.internal.addHeaderLenient
import okhttp3.internal.connection.RealConnection
import okhttp3.internal.headersContentLength
import okhttp3.internal.http.ExchangeCodec
Expand Down Expand Up @@ -189,7 +188,7 @@ class Http2ExchangeCodec(
if (name == RESPONSE_STATUS_UTF8) {
statusLine = StatusLine.parse("HTTP/1.1 $value")
} else if (name !in HTTP_2_SKIPPED_RESPONSE_HEADERS) {
addHeaderLenient(headersBuilder, name, value)
headersBuilder.addLenient(name, value)
}
}
if (statusLine == null) throw ProtocolException("Expected ':status' header not present")
Expand Down

0 comments on commit 5a344e6

Please sign in to comment.