Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension URLRequest {
- func property(forKey key: String) -> Any? {
- return URLProtocol.property(forKey: key, in: self)
- }
- mutating func setProperty(_ value: Any, forKey key: String) {
- mutate { URLProtocol.setProperty(value, forKey: key, in: $0) }
- }
- mutating func removeProperty(forKey key: String) {
- mutate { URLProtocol.removeProperty(forKey: key, in: $0) }
- }
- private mutating func mutate(_ block: (NSMutableURLRequest) -> Void) {
- let mutableURLRequest = self as! NSMutableURLRequest
- block(mutableURLRequest)
- self = mutableURLRequest as URLRequest
- }
- }
Add Comment
Please, Sign In to add comment