         return !(lhs == rhs)
     }
 }
+
+extension HTTPURLResponse {
+    public var isSuccess: Bool {
+        return 200...299 ~= statusCode
+    }
+}

        case began
        case inProgress(CGFloat)
        case completed(Result<URL>)
    }
    
    public let url: URL

    // MARK: NSURLSessionDownloadDelegate
    
    public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
        if let httpResponse = downloadTask.response as? HTTPURLResponse, !httpResponse.isSuccess {
            updater?(.completed(.failure(DownloaderError.httpRequestFailed)))
            return
        }

        updater?(.completed(.success(location)))
        updater = nil
    }
