Skip to content

Commit c2d658b

Browse files
authored
fix: relaxed Content-Type checks for CLI download (#189)
This PR fixes download failure for Windows .exe binaries by relaxing strict Content-Type checks. Previously, the plugin only accepted application/octet-stream, causing failures when .exe files were served as application/x-msdos-executable by some servers. - resolves #187
1 parent a68ab3a commit c2d658b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Fixed
1010

1111
- NPE during error reporting
12+
- relaxed `Content-Type` checks while downloading the CLI
1213

1314
## 0.6.3 - 2025-08-25
1415

src/main/kotlin/com/coder/toolbox/cli/downloader/CoderDownloadService.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ import java.util.zip.GZIPInputStream
2525
import kotlin.io.path.name
2626
import kotlin.io.path.notExists
2727

28+
private val SUPPORTED_BIN_MIME_TYPES = listOf(
29+
"application/octet-stream",
30+
"application/exe",
31+
"application/dos-exe",
32+
"application/msdos-windows",
33+
"application/x-exe",
34+
"application/x-msdownload",
35+
"application/x-winexe",
36+
"application/x-msdos-program",
37+
"application/x-msdos-executable",
38+
"application/vnd.microsoft.portable-executable"
39+
)
2840
/**
2941
* Handles the download steps of Coder CLI
3042
*/
@@ -52,7 +64,7 @@ class CoderDownloadService(
5264
return when (response.code()) {
5365
HTTP_OK -> {
5466
val contentType = response.headers()["Content-Type"]?.lowercase()
55-
if (contentType?.startsWith("application/octet-stream") != true) {
67+
if (contentType !in SUPPORTED_BIN_MIME_TYPES) {
5668
throw ResponseException(
5769
"Invalid content type '$contentType' when downloading CLI from $remoteBinaryURL. Expected application/octet-stream.",
5870
response.code()

0 commit comments

Comments
 (0)