revert freebee changes

This commit is contained in:
Pan, Xinlei (Ryan) 2018-05-10 11:46:48 -04:00
parent ebb5303711
commit 995b3119ba
2 changed files with 35 additions and 12 deletions

View File

@ -44,7 +44,8 @@ typedef void(^FreebeeLoadFinishedHandler)(MVMCoreOperation* _Nullable freebeeOpe
- (BOOL)isFreeBeeAuthorizedValidUrl:(nullable NSURL*)url; - (BOOL)isFreeBeeAuthorizedValidUrl:(nullable NSURL*)url;
- (nullable NSString*)urlForidFromConfigDict:(nonnull NSString*)urlId; - (nullable NSString*)urlForidFromConfigDict:(nonnull NSString*)urlId;
- (nullable NSCachedURLResponse*)freebee_dataWithContentsOfURL:(NSURL *_Nullable)url; - (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *_Nullable)url;
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *_Nullable)imageURL;
- (void)configureFreeBeeWithDict:(nullable NSDictionary*)configDict withSessionReset:(BOOL)isReset; - (void)configureFreeBeeWithDict:(nullable NSDictionary*)configDict withSessionReset:(BOOL)isReset;
@end @end

View File

@ -230,31 +230,53 @@ typedef NS_ENUM(NSUInteger, FreeBeeCampaignState) {
} }
#pragma mark FreeBee Helper for NSData #pragma mark FreeBee Helper for NSData
- (nullable NSCachedURLResponse*)freebee_dataWithContentsOfURL:(NSURL *)url { - (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *)url {
NSData* data = nil; NSData* data = nil;
NSDictionary* proxyDict = [self proxyDictionaryforUrl:url]; NSDictionary* proxyDict = [self proxyDictionaryforUrl:url];
NSURLResponse* response = nil;
NSError* error = nil;
if ([self isFreeBeeEnabled] && if ([self isFreeBeeEnabled] &&
[self isValidCampaign] && proxyDict && [self isValidCampaign] && proxyDict &&
![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) { ![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) {
MVMCoreLog(@"Free Data Url, %@", url); MVMCoreLog(@"Free Data Url, %@", url);
NSURLResponse* response = nil;
NSError* error = nil;
data = [self sendSynchronousRequest:url returningResponse:&response error:&error]; data = [self sendSynchronousRequest:url returningResponse:&response error:&error];
if (error)
data = nil;
MVMCoreLog(@"freebee_dataWithContentsOfURL:Free Data, %lu", (unsigned long)data.length);
} else {
data = [NSData dataWithContentsOfURL:url];
}
return data;
}
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *)imageURL {
NSData* data = nil;
NSDictionary* proxyDict = [self proxyDictionaryforUrl:imageURL];
if ([self isFreeBeeEnabled] &&
[self isValidCampaign] && proxyDict &&
![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) {
MVMCoreLog(@"Free Image Data Url, %@", imageURL);
NSURLResponse* response = nil;
NSError* error = nil;
data = [self sendSynchronousRequest:imageURL returningResponse:&response error:&error];
if (error) { if (error) {
data = nil; data = nil;
} }
MVMCoreLog(@"freebee_dataWithContentsOfURL:Free Data, %lu", (unsigned long)data.length);
} else { MVMCoreLog(@"freebee_dataWithImageURL:Free Image Data, %lu", (unsigned long)data.length);
//create response for identify NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
response = [[NSURLResponse alloc] initWithURL:url MIMEType:nil expectedContentLength:100 textEncodingName:nil]; return cachedResponse;
data = [NSData dataWithContentsOfURL:url];
} }
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data]; return nil;
return cachedResponse;
} }
#pragma mark - FreeBee Registration #pragma mark - FreeBee Registration