Skip to content

Commit 871c655

Browse files
Trevörweissi
Trevör
authored andcommitted
Remove parts of #139 relying on the Network framework (#147)
Use the UNIX implementation across all platforms to avoid unnecessary complexity introduced by platform specific implementations
1 parent 669745f commit 871c655

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

Sources/AsyncHTTPClient/Utils.swift

+9-23
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,17 @@
1515
import NIO
1616
import NIOHTTP1
1717

18-
#if canImport(Network)
19-
import Network
20-
21-
internal extension String {
22-
var isIPAddress: Bool {
23-
if IPv4Address(self) != nil || IPv6Address(self) != nil {
24-
return true
25-
}
26-
return false
18+
internal extension String {
19+
var isIPAddress: Bool {
20+
var ipv4Addr = in_addr()
21+
var ipv6Addr = in6_addr()
22+
23+
return self.withCString { ptr in
24+
inet_pton(AF_INET, ptr, &ipv4Addr) == 1 ||
25+
inet_pton(AF_INET6, ptr, &ipv6Addr) == 1
2726
}
2827
}
29-
30-
#else
31-
internal extension String {
32-
var isIPAddress: Bool {
33-
var ipv4Addr = in_addr()
34-
var ipv6Addr = in6_addr()
35-
36-
return self.withCString { ptr in
37-
inet_pton(AF_INET, ptr, &ipv4Addr) == 1 ||
38-
inet_pton(AF_INET6, ptr, &ipv6Addr) == 1
39-
}
40-
}
41-
}
42-
#endif
28+
}
4329

4430
public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate {
4531
public typealias Response = Void

0 commit comments

Comments
 (0)