Skip to content
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

Retry a task? #299

Open
valentinjahanmanesh opened this issue Nov 3, 2018 · 0 comments
Open

Retry a task? #299

valentinjahanmanesh opened this issue Nov 3, 2018 · 0 comments

Comments

@valentinjahanmanesh
Copy link

is there any way to retry a task or i have to implement it by my self? i mean retry a task after receiving the response :

//handle task finishing
      public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
          guard let resp = responseForTask(task) else { return }
          resp.error = error as NSError?
          if let hresponse = task.response as? HTTPURLResponse {
            resp.headers = hresponse.allHeaderFields as? Dictionary<String,String>
            resp.mimeType = hresponse.mimeType
            resp.suggestedFilename = hresponse.suggestedFilename
            resp.statusCode = hresponse.statusCode
            resp.URL = hresponse.url
        }
        
        if let code = resp.statusCode, code > 299 {
            //-1001//
            resp.error = createError(code)
        }
        if let handler = resp.completionHandler {
            handler(resp)
        }
        
        removeTask(task)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant