-
Notifications
You must be signed in to change notification settings - Fork 1.2k
HTTP Basic Auth implementation #1569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -192,3 +192,21 @@ open class URLAuthenticationChallenge : NSObject, NSSecureCoding { | |||
} | |||
} | |||
} | |||
|
|||
extension _HTTPURLProtocol : URLAuthenticationChallengeSender { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must add NSUnimplemented()
or fatalError()
with a message to these empty methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ..Thanks
@swift-ci please test |
let host = response.url?.host ?? "" | ||
let port = response.url?.port ?? 80 //we're doing http | ||
let _protocol = response.url?.scheme | ||
let wwwAuthHeader = response.allHeaderFields["WWW-Authenticate"] as! String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle the case where the WWW-Authenticate
header isn't present.
538082e
to
2e67353
Compare
bc896a6
to
ec4f3ea
Compare
@pushkarnk As of now the code is crashing when the header |
@@ -580,7 +616,24 @@ extension _ProtocolClient : URLProtocolClient { | |||
} | |||
|
|||
func urlProtocol(_ protocol: URLProtocol, didReceive challenge: URLAuthenticationChallenge) { | |||
NSUnimplemented() | |||
guard let task = `protocol`.task else { fatalError() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call fatalError()
with a clear error message.
@@ -580,7 +616,24 @@ extension _ProtocolClient : URLProtocolClient { | |||
} | |||
|
|||
func urlProtocol(_ protocol: URLProtocol, didReceive challenge: URLAuthenticationChallenge) { | |||
NSUnimplemented() | |||
guard let task = `protocol`.task else { fatalError() } | |||
guard let session = task.session as? URLSession else { fatalError() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call fatalError() with a clear error message.
@saiHemak Please correct the typo in the commit message as well. Thanks. |
@swift-ci please test |
@swift-ci please test and merge |
3 similar comments
@swift-ci please test and merge |
@swift-ci please test and merge |
@swift-ci please test and merge |
This PR is based on #1407 . I have picked up the implementation from #1407 PR and added HTTPServer changes which are required for testing this functionality.
@pushkarnk please review