-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add OS version info to user agent for Linux & Windows #738
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comment on using ProcessInfo from swift-foundations instead of using Glibc
#elseif os(Linux) | ||
import Glibc | ||
public struct PlatformOperationSystemVersion { | ||
static public func operatingSystemVersion() -> String? { | ||
var sysInfo = utsname() | ||
uname(&sysInfo) | ||
var local = sysInfo | ||
let releaseVersion = withUnsafePointer(to: &local.release) { | ||
$0.withMemoryRebound(to: CChar.self, capacity: MemoryLayout.size(ofValue: sysInfo.release)) { | ||
String(cString: $0) | ||
} | ||
} | ||
return releaseVersion | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swift-foundations provides ProcessInfo have you tried that out? It looks like it has a linux implementation and perhaps even a windows implementation for obtaining operatingSystemVersion
. I think we can use that directly
} | ||
return releaseVersion | ||
} | ||
} | ||
#else | ||
// TODO: Implement for Linux & Windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove the TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue #
awslabs/aws-sdk-swift#1206
Description of changes
Delete no-longer-necessary compiler directives.
Apple recently implemented getting OS versions for Linux & Windows for us in
Foundation.ProcessInfo
.Tested on Linux via cloud desktop running Amazon Linux 2.
Example
User-Agent
header value from test run:Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.