Skip to content

Commit 871692f

Browse files
authored
fix socket connecting problem (#34)
* fix socket connecting problem * fix can init on all classes
1 parent 55fed79 commit 871692f

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Sources/NetShears/URLProtocol/NetworkInterceptorUrlProtocol.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class NetworkInterceptorUrlProtocol: URLProtocol {
2828
override class func canInit(with request: URLRequest) -> Bool {
2929
guard NetworkInterceptor.shared.shouldRequestModify(urlRequest: request) else { return false }
3030

31-
if NetworkInterceptorUrlProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil {
31+
if NetworkInterceptorUrlProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil ||
32+
request.value(forHTTPHeaderField: "Connection") == "Upgrade" {
3233
return actionModifier(forRequest: request) != nil
3334
}
3435
return true

Sources/NetShears/URLProtocol/NetworkLoggerUrlProtocol.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class NetworkLoggerUrlProtocol: URLProtocol {
3232

3333
override class func canInit(with request: URLRequest) -> Bool {
3434

35-
if NetworkLoggerUrlProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil {
35+
if NetworkLoggerUrlProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil ||
36+
request.value(forHTTPHeaderField: "Connection") == "Upgrade" {
3637
return false
3738
}
3839
return true

Sources/NetShears/URLProtocol/NetwrokListenerUrlProtocol.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class NetwrokListenerUrlProtocol: URLProtocol {
3232

3333
override class func canInit(with request: URLRequest) -> Bool {
3434

35-
if NetwrokListenerUrlProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil {
35+
if NetwrokListenerUrlProtocol.property(forKey: Constants.RequestHandledKey, in: request) != nil ||
36+
request.value(forHTTPHeaderField: "Connection") == "Upgrade" {
3637
return false
3738
}
3839
return true

0 commit comments

Comments
 (0)