feat(useragent): add Windows support for getUname() to get User-Agent. #1333
+144
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
// TODO: if there is appetite for it in the community
// add support for Windows GetSystemInfo
✅ I do have appetite for this! I’d be happy to extend the implementation to include GetSystemInfo or any additional support from the community as it becomes available or necessary.
Feature: Add Windows Support for getUname() in User Agent, similar to the existing Unix support.
This PR adds a Windows-specific implementation of the
getUname()
function to match the format and style used on Unix systems. It is designed to support consistent system identification for tools like Stripe CLI or other cross-platform utilities.Summary
getUname()
for Windows systems.Example:
OUTPUT
"Windows DESKTOP-EGCRO4R 10.0.19045 Build 19045 x86_64
🔧 Technical Details
✅ Uses from
x/sys/windows
windows.GetComputerName
– gets the local hostname.windows.UTF16ToString
– converts UTF-16 output.❗ Manually defined (not in
x/sys/windows
)RtlGetVersion
– for accurate OS version info (fromntdll.dll
).SYSTEM_INFO
struct – to get CPU architecture viaGetNativeSystemInfo
.PROCESSOR_ARCHITECTURE_AMD64
,ARM64
, etc.🧱 Reason for Manual Definitions
🔒 Safety Notes
RtlGetVersion
is the officially recommended way (by Microsoft) to get OS version, unlikeGetVersionEx
orsyscall.GetVersion()
which are deprecated or inaccurate post-Windows 8.1.sysinfoapi.h
,winnt.h
).✅ Unit Test Included
TEST RESULT PHOTOS
I am using this on a Windows machine. Please find the attached photo for reference.