-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Closed
Labels
enhancementFeature not a bugFeature not a bug
Description
When trying to add new headers inside an interceptor, I usually do the following:
OkHttpClient.Builder()
.addInterceptor { chain ->
chain.proceed(
chain.request()
.newBuilder()
.addHeader(X, Y)
.build()
)
}But what if I want to use the internal header builder addUnsafeNonAscii method? There isn't any shortcut for that.
The workaround is something like:
OkHttpClient.Builder()
.addInterceptor { chain ->
chain.proceed(
chain.request()
.newBuilder()
//We need to use headers already in the request.
.headers(chain.request().headers.newBuilder().apply {
addUnsafeNonAscii(X, Y)
}.build())
.build()
)
}It would be easy to add a new addUnsafeNonAscii method to Request.Builder that will use the internal header builder's addUnsafeNonAscii.
Metadata
Metadata
Assignees
Labels
enhancementFeature not a bugFeature not a bug