Make HTTPConditionalGetInfo serialize and deserialize to a plist.
This commit is contained in:
parent
f17f31ba12
commit
a336140a9a
|
@ -18,6 +18,22 @@ public struct HTTPConditionalGetInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var plist: [String: String]? {
|
||||||
|
get {
|
||||||
|
if isEmpty {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var d = [String: String]()
|
||||||
|
if let lastModified = lastModified {
|
||||||
|
d[HTTPResponseHeader.lastModified] = lastModified
|
||||||
|
}
|
||||||
|
if let etag = etag {
|
||||||
|
d[HTTPResponseHeader.etag] = etag
|
||||||
|
}
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public init(lastModified: String?, etag: String?) {
|
public init(lastModified: String?, etag: String?) {
|
||||||
|
|
||||||
self.lastModified = lastModified
|
self.lastModified = lastModified
|
||||||
|
@ -32,6 +48,11 @@ public struct HTTPConditionalGetInfo {
|
||||||
self.init(lastModified: lastModified, etag: etag)
|
self.init(lastModified: lastModified, etag: etag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public init(plist: [String: String]) {
|
||||||
|
|
||||||
|
self.init(lastModified: plist[HTTPResponseHeader.lastModified], etag: plist[HTTPResponseHeader.etag])
|
||||||
|
}
|
||||||
|
|
||||||
public func addRequestHeadersToURLRequest(_ urlRequest: NSMutableURLRequest) {
|
public func addRequestHeadersToURLRequest(_ urlRequest: NSMutableURLRequest) {
|
||||||
|
|
||||||
if let lastModified = lastModified {
|
if let lastModified = lastModified {
|
||||||
|
|
Loading…
Reference in New Issue