Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTTP.globalRequest { req in
- req.timeoutInterval = 5
- }
- //set a global SSL pinning setting
- HTTP.globalSecurity(HTTPSecurity()) //see the SSL section for more info
- //set global auth handler. See the Auth section for more info
- HTTP.globalAuth { challenge in
- return URLCredential(user: "user", password: "passwd", persistence: .forSession)
- }
- do {
- let opt = try HTTP.GET("https://10.0.1.2:4711/fhem/?cmd=jsonlist2&XHR=1",requestSerializer: JSONParameterSerializer())
- //the auth closures will continually be called until a successful auth or rejection
- var attempted = false
- opt.auth = { challenge in
- if !attempted {
- attempted = true
- return URLCredential(forTrust: challenge.proposedCredential?.certificates)
- }
- return nil
- }
- opt.start { response in
- print("success")
- print("opt finished: (response.data)")
- }
- } catch let error {
- print("got an error creating the request: (error)")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement