Skip to content

Commit 599c041

Browse files
fix: send coder User-Agent on workspace app icon fetches (#268)
1 parent ce2d4a4 commit 599c041

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎Coder-Desktop/Coder-Desktop/Coder_DesktopApp.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import CoderSDK
12
import FluidMenuBarExtra
23
import NetworkExtension
34
import os
@@ -102,6 +103,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
102103
UserDefaults.standard.setValue(Theme.Animation.tooltipDelay, forKey: "NSInitialToolTipDelay")
103104
// Init SVG loader
104105
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
106+
SDWebImageDownloader.shared.setValue(CoderSDK.userAgent(component: .app), forHTTPHeaderField: "User-Agent")
105107

106108
menuBar = .init(menuBarExtra: FluidMenuBarExtra(
107109
title: "Coder Desktop",

‎Coder-Desktop/CoderSDK/UserAgent.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ enum UserAgentDefaults {
2828
}
2929

3030
/// Formats a `User-Agent` as `<token>/<version> (<goos>/<goarch>)`.
31-
func userAgent(
32-
component: CoderComponent,
33-
version: String = UserAgentDefaults.version,
34-
arch: GoArch = UserAgentDefaults.arch
35-
) -> String {
31+
public func userAgent(component: CoderComponent) -> String {
32+
userAgent(component: component, version: UserAgentDefaults.version, arch: UserAgentDefaults.arch)
33+
}
34+
35+
func userAgent(component: CoderComponent, version: String, arch: GoArch) -> String {
3636
"\(component.rawValue)/\(version) (\(UserAgentDefaults.goos)/\(arch.rawValue))"
3737
}
3838

0 commit comments

Comments
 (0)