Skip to content

Commit 8e999b4

Browse files
authored
Merge pull request #110 from Cysharp/feature/ThrowUDSNotSupportedOnWindows
Throw PlatformNotSupportedException when trying to use UDS on Windows
2 parents 940d96d + a8e6fc5 commit 8e999b4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/YetAnotherHttpHandler/NativeHttpHandlerCore.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ private unsafe void Initialize(YahaNativeContext* ctx, NativeClientSettings sett
187187
if (settings.UnixDomainSocketPath is { } unixDomainSocketPath)
188188
{
189189
if (YahaEventSource.Log.IsEnabled()) YahaEventSource.Log.Info($"Option '{nameof(settings.UnixDomainSocketPath)}' = {unixDomainSocketPath}");
190+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
191+
{
192+
throw new PlatformNotSupportedException("Unix domain socket is not supported on Windows.");
193+
}
190194
var strBytes = Encoding.UTF8.GetBytes(unixDomainSocketPath);
191195
fixed (byte* buffer = strBytes)
192196
{

test/YetAnotherHttpHandler.Test/UdsTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,25 @@ protected override Task<TestWebAppServer> LaunchServerAsyncCore<T>(Action<WebApp
4040
configure?.Invoke(builder);
4141
});
4242
}
43+
}
44+
45+
[OSSkipCondition(OperatingSystems.MacOSX | OperatingSystems.Linux)]
46+
public class UdsNotSupportedTest
47+
{
48+
[ConditionalFact]
49+
public async Task Throw()
50+
{
51+
// Arrange
52+
var handler = new YetAnotherHttpHandler()
53+
{
54+
UnixDomainSocketPath = "/path/to/socket",
55+
};
56+
var httpClient = new HttpClient(handler);
57+
58+
// Act & Assert
59+
await Assert.ThrowsAsync<PlatformNotSupportedException>(async () =>
60+
{
61+
await httpClient.GetAsync("http://localhost/");
62+
});
63+
}
4364
}

0 commit comments

Comments
 (0)