forked from kevmuko/AdBlocker-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilteredWebCache.m
36 lines (30 loc) · 1.06 KB
/
FilteredWebCache.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// FilteredWebCache.m
// Zeusmos
//
// Created by Kevin Ko on 9/30/12.
// Copyright (c) 2012 uhelios. All rights reserved.
//
#import "FilteredWebCache.h"
#import "AdBlocker.h"
@implementation FilteredWebCache
- (NSCachedURLResponse*)cachedResponseForRequest:(NSURLRequest*)request
{
NSURL *url = [request URL];
BOOL blockURL = [[AdBlocker sharedInstance] examineURL:[url relativeString]];
if (blockURL) {
NSURLResponse *response =
[[NSURLResponse alloc] initWithURL:url
MIMEType:@"text/plain"
expectedContentLength:1
textEncodingName:nil];
NSCachedURLResponse *cachedResponse =
[[NSCachedURLResponse alloc] initWithResponse:response
data:[NSData dataWithBytes:" " length:1]];
[super storeCachedResponse:cachedResponse forRequest:request];
[cachedResponse release];
[response release];
}
return [super cachedResponseForRequest:request];
}
@end