Skip to content

Commit d82e875

Browse files
Put Brotli and Gzip in top-level files (#9116)
This doesn't have any impact on compatibility. Co-authored-by: Jesse Wilson <[email protected]>
1 parent d4a5be1 commit d82e875

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2019 Square, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package okhttp3.brotli
17+
18+
import okhttp3.CompressionInterceptor
19+
import okio.BufferedSource
20+
import okio.Source
21+
import okio.source
22+
import org.brotli.dec.BrotliInputStream
23+
24+
object Brotli : CompressionInterceptor.DecompressionAlgorithm {
25+
override val encoding: String get() = "br"
26+
27+
override fun decompress(compressedSource: BufferedSource): Source = BrotliInputStream(compressedSource.inputStream()).source()
28+
}

okhttp-brotli/src/main/kotlin/okhttp3/brotli/BrotliInterceptor.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ package okhttp3.brotli
1717

1818
import okhttp3.CompressionInterceptor
1919
import okhttp3.Gzip
20-
import okio.BufferedSource
21-
import okio.Source
22-
import okio.source
23-
import org.brotli.dec.BrotliInputStream
2420

2521
/**
2622
* Transparent Brotli response support.
@@ -29,9 +25,3 @@ import org.brotli.dec.BrotliInputStream
2925
* responses. n.b. this replaces the transparent gzip compression in BridgeInterceptor.
3026
*/
3127
object BrotliInterceptor : CompressionInterceptor(Brotli, Gzip)
32-
33-
object Brotli : CompressionInterceptor.DecompressionAlgorithm {
34-
override val encoding: String get() = "br"
35-
36-
override fun decompress(compressedSource: BufferedSource): Source = BrotliInputStream(compressedSource.inputStream()).source()
37-
}

okhttp/src/commonJvmAndroid/kotlin/okhttp3/CompressionInterceptor.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
*/
1616
package okhttp3
1717

18-
import okhttp3.CompressionInterceptor.DecompressionAlgorithm
1918
import okhttp3.ResponseBody.Companion.asResponseBody
2019
import okhttp3.internal.http.promisesBody
2120
import okio.BufferedSource
22-
import okio.GzipSource
2321
import okio.Source
2422
import okio.buffer
2523

@@ -95,9 +93,3 @@ open class CompressionInterceptor(
9593
fun decompress(compressedSource: BufferedSource): Source
9694
}
9795
}
98-
99-
object Gzip : DecompressionAlgorithm {
100-
override val encoding: String get() = "gzip"
101-
102-
override fun decompress(compressedSource: BufferedSource): Source = GzipSource(compressedSource)
103-
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025 Block, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package okhttp3
17+
18+
import okhttp3.CompressionInterceptor.DecompressionAlgorithm
19+
import okio.BufferedSource
20+
import okio.GzipSource
21+
import okio.Source
22+
23+
object Gzip : DecompressionAlgorithm {
24+
override val encoding: String get() = "gzip"
25+
26+
override fun decompress(compressedSource: BufferedSource): Source = GzipSource(compressedSource)
27+
}

0 commit comments

Comments
 (0)