NSURLResponse+Haneke.swift 503 B

12345678910111213141516171819202122
  1. //
  2. // NSHTTPURLResponse+Haneke.swift
  3. // Haneke
  4. //
  5. // Created by Hermes Pique on 9/12/14.
  6. // Copyright (c) 2014 Haneke. All rights reserved.
  7. //
  8. import Foundation
  9. extension URLResponse {
  10. func hnk_validateLength(ofData data: Data) -> Bool {
  11. let expectedContentLength = self.expectedContentLength
  12. if (expectedContentLength > -1) {
  13. let dataLength = data.count
  14. return Int64(dataLength) >= expectedContentLength
  15. }
  16. return true
  17. }
  18. }