Skip to content

Commit 1ac681c

Browse files
committed
Accept gzip when downloading binary
1 parent ae7b8df commit 1ac681c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/kotlin/com/coder/gateway/sdk/CoderCLIManager.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import java.nio.file.StandardCopyOption
1515
import java.nio.file.attribute.PosixFilePermissions
1616
import java.security.DigestInputStream
1717
import java.security.MessageDigest
18+
import java.util.zip.GZIPInputStream
1819
import javax.xml.bind.annotation.adapters.HexBinaryAdapter
1920

2021

@@ -86,14 +87,19 @@ class CoderCLIManager(deployment: URL) {
8687
logger.info("Found existing binary at ${localBinaryPath.toAbsolutePath()}; calculated hash as $etag")
8788
conn.setRequestProperty("If-None-Match", "\"$etag\"")
8889
}
90+
conn.setRequestProperty("Accept-Encoding", "gzip")
8991
conn.connect()
9092
logger.info("GET ${conn.responseCode} $remoteBinaryUrl")
9193
when (conn.responseCode) {
9294
200 -> {
9395
logger.info("Downloading binary to ${localBinaryPath.toAbsolutePath()}")
9496
Files.createDirectories(destinationDir)
9597
conn.inputStream.use {
96-
Files.copy(it, localBinaryPath, StandardCopyOption.REPLACE_EXISTING)
98+
Files.copy(
99+
if (conn.contentEncoding == "gzip") GZIPInputStream(it) else it,
100+
localBinaryPath,
101+
StandardCopyOption.REPLACE_EXISTING,
102+
)
97103
}
98104
if (getOS() != OS.WINDOWS) {
99105
Files.setPosixFilePermissions(

0 commit comments

Comments
 (0)