Przeglądaj źródła

Linux: Revert Add HTTP file cache for now (as it's not in Foundation yet)

Julien Chaumond 10 lat temu
rodzic
commit
ecb4089eb4
1 zmienionych plików z 1 dodań i 9 usunięć
  1. 1 9
      Sources/Swifter/HttpHandlers.swift

+ 1 - 9
Sources/Swifter/HttpHandlers.swift

@@ -10,8 +10,6 @@ public class HttpHandlers {
     
     private static let rangeExpression = try! NSRegularExpression(pattern: "bytes=(\\d*)-(\\d*)", options: .CaseInsensitive)
     
-    private static let cache = NSCache()
-    
     public class func directory(dir: String) -> (HttpRequest -> HttpResponse) {
         return { request in
             
@@ -21,16 +19,10 @@ public class HttpHandlers {
             
             let filesPath = dir + "/" + localPath.1
             
-            let cachedBody = cache.objectForKey(filesPath) as? NSData
-            
-            guard let fileBody = cachedBody ?? NSData(contentsOfFile: filesPath) else {
+            guard let fileBody = NSData(contentsOfFile: filesPath) else {
                 return HttpResponse.NotFound
             }
             
-            if cachedBody == nil {
-                cache.setObject(fileBody, forKey: filesPath)
-            }
-            
             if let rangeHeader = request.headers["range"] {
                 
                 guard let match = rangeExpression.matchesInString(rangeHeader, options: .Anchored, range: NSRange(location: 0, length: rangeHeader.characters.count)).first where match.numberOfRanges == 3 else {