@@ -50,10 +50,10 @@ public final class NIOHTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableC
50
50
/// - deadline: Deadline for the CONNECT request
51
51
/// - promise: Promise with which the result of the connect operation is communicated
52
52
public init ( targetHost: String ,
53
- targetPort: Int ,
54
- headers: HTTPHeaders ,
55
- deadline: NIODeadline ,
56
- promise: EventLoopPromise < Void > ) {
53
+ targetPort: Int ,
54
+ headers: HTTPHeaders ,
55
+ deadline: NIODeadline ,
56
+ promise: EventLoopPromise < Void > ) {
57
57
self . targetHost = targetHost
58
58
self . targetPort = targetPort
59
59
self . headers = headers
@@ -208,16 +208,61 @@ public final class NIOHTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableC
208
208
209
209
/// Error types for ``HTTP1ProxyConnectHandler``
210
210
public struct Error : Swift . Error , Equatable {
211
-
212
- fileprivate enum ErrorEnum : Equatable {
211
+ fileprivate enum Storage : Equatable , Hashable {
213
212
case proxyAuthenticationRequired
214
213
case invalidProxyResponseHead( head: HTTPResponseHead )
215
214
case invalidProxyResponse
216
215
case remoteConnectionClosed
217
216
case httpProxyHandshakeTimeout
218
217
case noResult
218
+
219
+ @inlinable
220
+ static func == ( lhs: Self , rhs: Self ) -> Bool {
221
+ return Kind ( from: lhs) == Kind ( from: rhs)
222
+ }
223
+
224
+ @inlinable
225
+ public func hash( into hasher: inout Hasher ) {
226
+ hasher. combine ( Kind ( from: self ) )
227
+ }
228
+ }
229
+
230
+ fileprivate enum Kind : Equatable , Hashable {
231
+ case proxyAuthenticationRequired
232
+ case invalidProxyResponseHead
233
+ case invalidProxyResponse
234
+ case remoteConnectionClosed
235
+ case httpProxyHandshakeTimeout
236
+ case noResult
237
+
238
+ init ( from storage: Storage ) {
239
+ switch storage {
240
+ case . proxyAuthenticationRequired:
241
+ self = . proxyAuthenticationRequired
242
+ case . invalidProxyResponseHead:
243
+ self = . invalidProxyResponseHead
244
+ case . invalidProxyResponse:
245
+ self = . invalidProxyResponse
246
+ case . remoteConnectionClosed:
247
+ self = . remoteConnectionClosed
248
+ case . httpProxyHandshakeTimeout:
249
+ self = . httpProxyHandshakeTimeout
250
+ case . noResult:
251
+ self = . noResult
252
+ }
253
+ }
254
+ }
255
+
256
+ fileprivate let error : Storage
257
+
258
+ public var file : String
259
+ public var line : Int
260
+
261
+ fileprivate init ( error: Storage , file: String = #file, line: Int = #line) {
262
+ self . error = error
263
+ self . file = file
264
+ self . line = line
219
265
}
220
- fileprivate let error : ErrorEnum
221
266
222
267
/// Proxy response status `407` indicates that authentication is required
223
268
public static let proxyAuthenticationRequired = Error ( error: . proxyAuthenticationRequired)
0 commit comments