|
35 | 35 | #import <WebKit/WebKit.h> |
36 | 36 | #endif |
37 | 37 |
|
38 | | -#define VERSION @"1.6.21" |
| 38 | +#define VERSION @"1.6.22" |
39 | 39 |
|
40 | 40 | #define PROPERTY_LENGTH_LIMITATION 8191 |
41 | 41 |
|
@@ -387,19 +387,28 @@ - (void)flushByType:(NSString *)type withSize:(int)flushSize andFlushMethod:(BOO |
387 | 387 | - (void)_flush:(BOOL) vacuumAfterFlushing { |
388 | 388 | // 使用 Post 发送数据 |
389 | 389 | BOOL (^flushByPost)(NSArray *, NSString *) = ^(NSArray *recordArray, NSString *type) { |
390 | | - // 1. 先完成这一系列Json字符串的拼接 |
391 | | - NSString *jsonString = [NSString stringWithFormat:@"[%@]",[recordArray componentsJoinedByString:@","]]; |
392 | | - // 2. 使用gzip进行压缩 |
393 | | - NSData *zippedData = [LFCGzipUtility gzipData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]]; |
394 | | - // 3. base64 |
395 | | - NSString *b64String = [zippedData sa_base64EncodedString]; |
396 | | - b64String = (id)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, |
397 | | - (CFStringRef)b64String, |
398 | | - NULL, |
399 | | - CFSTR("!*'();:@&=+$,/?%#[]"), |
400 | | - kCFStringEncodingUTF8)); |
401 | | - |
402 | | - NSString *postBody = [NSString stringWithFormat:@"gzip=1&data_list=%@", b64String]; |
| 390 | + NSString *jsonString; |
| 391 | + NSData *zippedData; |
| 392 | + NSString *b64String; |
| 393 | + NSString *postBody; |
| 394 | + @try { |
| 395 | + // 1. 先完成这一系列Json字符串的拼接 |
| 396 | + jsonString = [NSString stringWithFormat:@"[%@]",[recordArray componentsJoinedByString:@","]]; |
| 397 | + // 2. 使用gzip进行压缩 |
| 398 | + zippedData = [LFCGzipUtility gzipData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]]; |
| 399 | + // 3. base64 |
| 400 | + b64String = [zippedData sa_base64EncodedString]; |
| 401 | + b64String = (id)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, |
| 402 | + (CFStringRef)b64String, |
| 403 | + NULL, |
| 404 | + CFSTR("!*'();:@&=+$,/?%#[]"), |
| 405 | + kCFStringEncodingUTF8)); |
| 406 | + |
| 407 | + postBody = [NSString stringWithFormat:@"gzip=1&data_list=%@", b64String]; |
| 408 | + } @catch (NSException *exception) { |
| 409 | + SAError(@"%@ flushByPost format data error: %@", self, exception); |
| 410 | + return YES; |
| 411 | + } |
403 | 412 |
|
404 | 413 | NSURL *URL = [NSURL URLWithString:self.serverURL]; |
405 | 414 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; |
|
0 commit comments