Skip to content

Commit ff4a7fe

Browse files
feat(client): send X-Stainless-Lang and X-Stainless-OS headers
1 parent 11b2877 commit ff4a7fe

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Orb/Core/ParamsBase.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ protected string QueryString(ClientOptions options)
163163
protected static void AddDefaultHeaders(HttpRequestMessage request, ClientOptions options)
164164
{
165165
request.Headers.Add("X-Stainless-Arch", GetOSArch());
166+
request.Headers.Add("X-Stainless-Lang", "csharp");
167+
request.Headers.Add("X-Stainless-OS", GetOS());
166168

167169
if (options.APIKey != null)
168170
{
@@ -183,4 +185,21 @@ or Architecture.LoongArch64
183185
or Architecture.Ppc64le => $"other:{RuntimeInformation.OSArchitecture}",
184186
_ => "unknown",
185187
};
188+
189+
static string GetOS()
190+
{
191+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
192+
{
193+
return "Windows";
194+
}
195+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
196+
{
197+
return "MacOS";
198+
}
199+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
200+
{
201+
return "Linux";
202+
}
203+
return $"Other:{RuntimeInformation.OSDescription}";
204+
}
186205
}

0 commit comments

Comments
 (0)