FLEXNetworkTransactionDetailTableViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. //
  2. // FLEXNetworkTransactionDetailTableViewController.m
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 2/10/15.
  6. // Copyright (c) 2015 Flipboard. All rights reserved.
  7. //
  8. #import "FLEXColor.h"
  9. #import "FLEXNetworkTransactionDetailTableViewController.h"
  10. #import "FLEXNetworkCurlLogger.h"
  11. #import "FLEXNetworkRecorder.h"
  12. #import "FLEXNetworkTransaction.h"
  13. #import "FLEXWebViewController.h"
  14. #import "FLEXImagePreviewViewController.h"
  15. #import "FLEXMultilineTableViewCell.h"
  16. #import "FLEXUtility.h"
  17. #import "FLEXManager+Private.h"
  18. typedef UIViewController *(^FLEXNetworkDetailRowSelectionFuture)(void);
  19. @interface FLEXNetworkDetailRow : NSObject
  20. @property (nonatomic, copy) NSString *title;
  21. @property (nonatomic, copy) NSString *detailText;
  22. @property (nonatomic, copy) FLEXNetworkDetailRowSelectionFuture selectionFuture;
  23. @end
  24. @implementation FLEXNetworkDetailRow
  25. @end
  26. @interface FLEXNetworkDetailSection : NSObject
  27. @property (nonatomic, copy) NSString *title;
  28. @property (nonatomic, copy) NSArray<FLEXNetworkDetailRow *> *rows;
  29. @end
  30. @implementation FLEXNetworkDetailSection
  31. @end
  32. @interface FLEXNetworkTransactionDetailTableViewController ()
  33. @property (nonatomic, copy) NSArray<FLEXNetworkDetailSection *> *sections;
  34. @end
  35. @implementation FLEXNetworkTransactionDetailTableViewController
  36. - (instancetype)initWithStyle:(UITableViewStyle)style
  37. {
  38. // Force grouped style
  39. self = [super initWithStyle:UITableViewStyleGrouped];
  40. if (self) {
  41. [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(handleTransactionUpdatedNotification:) name:kFLEXNetworkRecorderTransactionUpdatedNotification object:nil];
  42. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Copy curl" style:UIBarButtonItemStylePlain target:self action:@selector(copyButtonPressed:)];
  43. }
  44. return self;
  45. }
  46. - (void)viewDidLoad
  47. {
  48. [super viewDidLoad];
  49. [self.tableView registerClass:[FLEXMultilineTableViewCell class] forCellReuseIdentifier:kFLEXMultilineTableViewCellIdentifier];
  50. }
  51. - (void)setTransaction:(FLEXNetworkTransaction *)transaction
  52. {
  53. if (![_transaction isEqual:transaction]) {
  54. _transaction = transaction;
  55. self.title = [transaction.request.URL lastPathComponent];
  56. [self rebuildTableSections];
  57. }
  58. }
  59. - (void)setSections:(NSArray<FLEXNetworkDetailSection *> *)sections
  60. {
  61. if (![_sections isEqual:sections]) {
  62. _sections = [sections copy];
  63. [self.tableView reloadData];
  64. }
  65. }
  66. - (void)rebuildTableSections
  67. {
  68. NSMutableArray<FLEXNetworkDetailSection *> *sections = [NSMutableArray array];
  69. FLEXNetworkDetailSection *generalSection = [[self class] generalSectionForTransaction:self.transaction];
  70. if (generalSection.rows.count > 0) {
  71. [sections addObject:generalSection];
  72. }
  73. FLEXNetworkDetailSection *requestHeadersSection = [[self class] requestHeadersSectionForTransaction:self.transaction];
  74. if (requestHeadersSection.rows.count > 0) {
  75. [sections addObject:requestHeadersSection];
  76. }
  77. FLEXNetworkDetailSection *queryParametersSection = [[self class] queryParametersSectionForTransaction:self.transaction];
  78. if (queryParametersSection.rows.count > 0) {
  79. [sections addObject:queryParametersSection];
  80. }
  81. FLEXNetworkDetailSection *postBodySection = [[self class] postBodySectionForTransaction:self.transaction];
  82. if (postBodySection.rows.count > 0) {
  83. [sections addObject:postBodySection];
  84. }
  85. FLEXNetworkDetailSection *responseHeadersSection = [[self class] responseHeadersSectionForTransaction:self.transaction];
  86. if (responseHeadersSection.rows.count > 0) {
  87. [sections addObject:responseHeadersSection];
  88. }
  89. self.sections = sections;
  90. }
  91. - (void)handleTransactionUpdatedNotification:(NSNotification *)notification
  92. {
  93. FLEXNetworkTransaction *transaction = [[notification userInfo] objectForKey:kFLEXNetworkRecorderUserInfoTransactionKey];
  94. if (transaction == self.transaction) {
  95. [self rebuildTableSections];
  96. }
  97. }
  98. - (void)copyButtonPressed:(id)sender
  99. {
  100. [UIPasteboard.generalPasteboard setString:[FLEXNetworkCurlLogger curlCommandString:_transaction.request]];
  101. }
  102. #pragma mark - Table view data source
  103. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  104. {
  105. return self.sections.count;
  106. }
  107. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  108. {
  109. FLEXNetworkDetailSection *sectionModel = self.sections[section];
  110. return sectionModel.rows.count;
  111. }
  112. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
  113. {
  114. FLEXNetworkDetailSection *sectionModel = self.sections[section];
  115. return sectionModel.title;
  116. }
  117. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  118. {
  119. FLEXMultilineTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kFLEXMultilineTableViewCellIdentifier forIndexPath:indexPath];
  120. FLEXNetworkDetailRow *rowModel = [self rowModelAtIndexPath:indexPath];
  121. cell.textLabel.attributedText = [[self class] attributedTextForRow:rowModel];
  122. cell.accessoryType = rowModel.selectionFuture ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
  123. cell.selectionStyle = rowModel.selectionFuture ? UITableViewCellSelectionStyleDefault : UITableViewCellSelectionStyleNone;
  124. return cell;
  125. }
  126. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  127. {
  128. FLEXNetworkDetailRow *rowModel = [self rowModelAtIndexPath:indexPath];
  129. UIViewController *viewControllerToPush = nil;
  130. if (rowModel.selectionFuture) {
  131. viewControllerToPush = rowModel.selectionFuture();
  132. }
  133. if (viewControllerToPush) {
  134. [self.navigationController pushViewController:viewControllerToPush animated:YES];
  135. }
  136. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  137. }
  138. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  139. {
  140. FLEXNetworkDetailRow *row = [self rowModelAtIndexPath:indexPath];
  141. NSAttributedString *attributedText = [[self class] attributedTextForRow:row];
  142. BOOL showsAccessory = row.selectionFuture != nil;
  143. return [FLEXMultilineTableViewCell preferredHeightWithAttributedText:attributedText inTableViewWidth:self.tableView.bounds.size.width style:UITableViewStyleGrouped showsAccessory:showsAccessory];
  144. }
  145. - (FLEXNetworkDetailRow *)rowModelAtIndexPath:(NSIndexPath *)indexPath
  146. {
  147. FLEXNetworkDetailSection *sectionModel = self.sections[indexPath.section];
  148. return sectionModel.rows[indexPath.row];
  149. }
  150. #pragma mark - Cell Copying
  151. - (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath
  152. {
  153. return YES;
  154. }
  155. - (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
  156. {
  157. return action == @selector(copy:);
  158. }
  159. - (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
  160. {
  161. if (action == @selector(copy:)) {
  162. FLEXNetworkDetailRow *row = [self rowModelAtIndexPath:indexPath];
  163. [UIPasteboard.generalPasteboard setString:row.detailText];
  164. }
  165. }
  166. #pragma mark - View Configuration
  167. + (NSAttributedString *)attributedTextForRow:(FLEXNetworkDetailRow *)row
  168. {
  169. NSDictionary<NSString *, id> *titleAttributes = @{ NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:12.0],
  170. NSForegroundColorAttributeName : [UIColor colorWithWhite:0.5 alpha:1.0] };
  171. NSDictionary<NSString *, id> *detailAttributes = @{ NSFontAttributeName : [FLEXUtility defaultTableViewCellLabelFont],
  172. NSForegroundColorAttributeName : [FLEXColor primaryTextColor] };
  173. NSString *title = [NSString stringWithFormat:@"%@: ", row.title];
  174. NSString *detailText = row.detailText ?: @"";
  175. NSMutableAttributedString *attributedText = [NSMutableAttributedString new];
  176. [attributedText appendAttributedString:[[NSAttributedString alloc] initWithString:title attributes:titleAttributes]];
  177. [attributedText appendAttributedString:[[NSAttributedString alloc] initWithString:detailText attributes:detailAttributes]];
  178. return attributedText;
  179. }
  180. #pragma mark - Table Data Generation
  181. + (FLEXNetworkDetailSection *)generalSectionForTransaction:(FLEXNetworkTransaction *)transaction
  182. {
  183. NSMutableArray<FLEXNetworkDetailRow *> *rows = [NSMutableArray array];
  184. FLEXNetworkDetailRow *requestURLRow = [FLEXNetworkDetailRow new];
  185. requestURLRow.title = @"Request URL";
  186. NSURL *url = transaction.request.URL;
  187. requestURLRow.detailText = url.absoluteString;
  188. requestURLRow.selectionFuture = ^{
  189. UIViewController *urlWebViewController = [[FLEXWebViewController alloc] initWithURL:url];
  190. urlWebViewController.title = url.absoluteString;
  191. return urlWebViewController;
  192. };
  193. [rows addObject:requestURLRow];
  194. FLEXNetworkDetailRow *requestMethodRow = [FLEXNetworkDetailRow new];
  195. requestMethodRow.title = @"Request Method";
  196. requestMethodRow.detailText = transaction.request.HTTPMethod;
  197. [rows addObject:requestMethodRow];
  198. if (transaction.cachedRequestBody.length > 0) {
  199. FLEXNetworkDetailRow *postBodySizeRow = [FLEXNetworkDetailRow new];
  200. postBodySizeRow.title = @"Request Body Size";
  201. postBodySizeRow.detailText = [NSByteCountFormatter stringFromByteCount:transaction.cachedRequestBody.length countStyle:NSByteCountFormatterCountStyleBinary];
  202. [rows addObject:postBodySizeRow];
  203. FLEXNetworkDetailRow *postBodyRow = [FLEXNetworkDetailRow new];
  204. postBodyRow.title = @"Request Body";
  205. postBodyRow.detailText = @"tap to view";
  206. postBodyRow.selectionFuture = ^{
  207. NSString *contentType = [transaction.request valueForHTTPHeaderField:@"Content-Type"];
  208. UIViewController *detailViewController = [self detailViewControllerForMIMEType:contentType data:[self postBodyDataForTransaction:transaction]];
  209. if (detailViewController) {
  210. detailViewController.title = @"Request Body";
  211. } else {
  212. NSString *alertMessage = [NSString stringWithFormat:@"FLEX does not have a viewer for request body data with MIME type: %@", [transaction.request valueForHTTPHeaderField:@"Content-Type"]];
  213. [[[UIAlertView alloc] initWithTitle:@"Can't View Body Data" message:alertMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
  214. }
  215. return detailViewController;
  216. };
  217. [rows addObject:postBodyRow];
  218. }
  219. NSString *statusCodeString = [FLEXUtility statusCodeStringFromURLResponse:transaction.response];
  220. if (statusCodeString.length > 0) {
  221. FLEXNetworkDetailRow *statusCodeRow = [FLEXNetworkDetailRow new];
  222. statusCodeRow.title = @"Status Code";
  223. statusCodeRow.detailText = statusCodeString;
  224. [rows addObject:statusCodeRow];
  225. }
  226. if (transaction.error) {
  227. FLEXNetworkDetailRow *errorRow = [FLEXNetworkDetailRow new];
  228. errorRow.title = @"Error";
  229. errorRow.detailText = transaction.error.localizedDescription;
  230. [rows addObject:errorRow];
  231. }
  232. FLEXNetworkDetailRow *responseBodyRow = [FLEXNetworkDetailRow new];
  233. responseBodyRow.title = @"Response Body";
  234. NSData *responseData = [[FLEXNetworkRecorder defaultRecorder] cachedResponseBodyForTransaction:transaction];
  235. if (responseData.length > 0) {
  236. responseBodyRow.detailText = @"tap to view";
  237. // Avoid a long lived strong reference to the response data in case we need to purge it from the cache.
  238. __weak NSData *weakResponseData = responseData;
  239. responseBodyRow.selectionFuture = ^{
  240. UIViewController *responseBodyDetailViewController = nil;
  241. NSData *strongResponseData = weakResponseData;
  242. if (strongResponseData) {
  243. responseBodyDetailViewController = [self detailViewControllerForMIMEType:transaction.response.MIMEType data:strongResponseData];
  244. if (!responseBodyDetailViewController) {
  245. NSString *alertMessage = [NSString stringWithFormat:@"FLEX does not have a viewer for responses with MIME type: %@", transaction.response.MIMEType];
  246. [[[UIAlertView alloc] initWithTitle:@"Can't View Response" message:alertMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
  247. }
  248. responseBodyDetailViewController.title = @"Response";
  249. } else {
  250. NSString *alertMessage = @"The response has been purged from the cache";
  251. [[[UIAlertView alloc] initWithTitle:@"Can't View Response" message:alertMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
  252. }
  253. return responseBodyDetailViewController;
  254. };
  255. } else {
  256. BOOL emptyResponse = transaction.receivedDataLength == 0;
  257. responseBodyRow.detailText = emptyResponse ? @"empty" : @"not in cache";
  258. }
  259. [rows addObject:responseBodyRow];
  260. FLEXNetworkDetailRow *responseSizeRow = [FLEXNetworkDetailRow new];
  261. responseSizeRow.title = @"Response Size";
  262. responseSizeRow.detailText = [NSByteCountFormatter stringFromByteCount:transaction.receivedDataLength countStyle:NSByteCountFormatterCountStyleBinary];
  263. [rows addObject:responseSizeRow];
  264. FLEXNetworkDetailRow *mimeTypeRow = [FLEXNetworkDetailRow new];
  265. mimeTypeRow.title = @"MIME Type";
  266. mimeTypeRow.detailText = transaction.response.MIMEType;
  267. [rows addObject:mimeTypeRow];
  268. FLEXNetworkDetailRow *mechanismRow = [FLEXNetworkDetailRow new];
  269. mechanismRow.title = @"Mechanism";
  270. mechanismRow.detailText = transaction.requestMechanism;
  271. [rows addObject:mechanismRow];
  272. NSDateFormatter *startTimeFormatter = [NSDateFormatter new];
  273. startTimeFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS";
  274. FLEXNetworkDetailRow *localStartTimeRow = [FLEXNetworkDetailRow new];
  275. localStartTimeRow.title = [NSString stringWithFormat:@"Start Time (%@)", [[NSTimeZone localTimeZone] abbreviationForDate:transaction.startTime]];
  276. localStartTimeRow.detailText = [startTimeFormatter stringFromDate:transaction.startTime];
  277. [rows addObject:localStartTimeRow];
  278. startTimeFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  279. FLEXNetworkDetailRow *utcStartTimeRow = [FLEXNetworkDetailRow new];
  280. utcStartTimeRow.title = @"Start Time (UTC)";
  281. utcStartTimeRow.detailText = [startTimeFormatter stringFromDate:transaction.startTime];
  282. [rows addObject:utcStartTimeRow];
  283. FLEXNetworkDetailRow *unixStartTime = [FLEXNetworkDetailRow new];
  284. unixStartTime.title = @"Unix Start Time";
  285. unixStartTime.detailText = [NSString stringWithFormat:@"%f", [transaction.startTime timeIntervalSince1970]];
  286. [rows addObject:unixStartTime];
  287. FLEXNetworkDetailRow *durationRow = [FLEXNetworkDetailRow new];
  288. durationRow.title = @"Total Duration";
  289. durationRow.detailText = [FLEXUtility stringFromRequestDuration:transaction.duration];
  290. [rows addObject:durationRow];
  291. FLEXNetworkDetailRow *latencyRow = [FLEXNetworkDetailRow new];
  292. latencyRow.title = @"Latency";
  293. latencyRow.detailText = [FLEXUtility stringFromRequestDuration:transaction.latency];
  294. [rows addObject:latencyRow];
  295. FLEXNetworkDetailSection *generalSection = [FLEXNetworkDetailSection new];
  296. generalSection.title = @"General";
  297. generalSection.rows = rows;
  298. return generalSection;
  299. }
  300. + (FLEXNetworkDetailSection *)requestHeadersSectionForTransaction:(FLEXNetworkTransaction *)transaction
  301. {
  302. FLEXNetworkDetailSection *requestHeadersSection = [FLEXNetworkDetailSection new];
  303. requestHeadersSection.title = @"Request Headers";
  304. requestHeadersSection.rows = [self networkDetailRowsFromDictionary:transaction.request.allHTTPHeaderFields];
  305. return requestHeadersSection;
  306. }
  307. + (FLEXNetworkDetailSection *)postBodySectionForTransaction:(FLEXNetworkTransaction *)transaction
  308. {
  309. FLEXNetworkDetailSection *postBodySection = [FLEXNetworkDetailSection new];
  310. postBodySection.title = @"Request Body Parameters";
  311. if (transaction.cachedRequestBody.length > 0) {
  312. NSString *contentType = [transaction.request valueForHTTPHeaderField:@"Content-Type"];
  313. if ([contentType hasPrefix:@"application/x-www-form-urlencoded"]) {
  314. NSString *bodyString = [NSString stringWithCString:[self postBodyDataForTransaction:transaction].bytes encoding:NSUTF8StringEncoding];
  315. postBodySection.rows = [self networkDetailRowsFromDictionary:[FLEXUtility dictionaryFromQuery:bodyString]];
  316. }
  317. }
  318. return postBodySection;
  319. }
  320. + (FLEXNetworkDetailSection *)queryParametersSectionForTransaction:(FLEXNetworkTransaction *)transaction
  321. {
  322. NSDictionary<NSString *, id> *queryDictionary = [FLEXUtility dictionaryFromQuery:transaction.request.URL.query];
  323. FLEXNetworkDetailSection *querySection = [FLEXNetworkDetailSection new];
  324. querySection.title = @"Query Parameters";
  325. querySection.rows = [self networkDetailRowsFromDictionary:queryDictionary];
  326. return querySection;
  327. }
  328. + (FLEXNetworkDetailSection *)responseHeadersSectionForTransaction:(FLEXNetworkTransaction *)transaction
  329. {
  330. FLEXNetworkDetailSection *responseHeadersSection = [FLEXNetworkDetailSection new];
  331. responseHeadersSection.title = @"Response Headers";
  332. if ([transaction.response isKindOfClass:[NSHTTPURLResponse class]]) {
  333. NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)transaction.response;
  334. responseHeadersSection.rows = [self networkDetailRowsFromDictionary:httpResponse.allHeaderFields];
  335. }
  336. return responseHeadersSection;
  337. }
  338. + (NSArray<FLEXNetworkDetailRow *> *)networkDetailRowsFromDictionary:(NSDictionary<NSString *, id> *)dictionary
  339. {
  340. NSMutableArray<FLEXNetworkDetailRow *> *rows = [NSMutableArray arrayWithCapacity:dictionary.count];
  341. NSArray<NSString *> *sortedKeys = [dictionary.allKeys sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
  342. for (NSString *key in sortedKeys) {
  343. id value = dictionary[key];
  344. FLEXNetworkDetailRow *row = [FLEXNetworkDetailRow new];
  345. row.title = key;
  346. row.detailText = [value description];
  347. [rows addObject:row];
  348. }
  349. return [rows copy];
  350. }
  351. + (UIViewController *)detailViewControllerForMIMEType:(NSString *)mimeType data:(NSData *)data
  352. {
  353. FLEXCustomContentViewerFuture makeCustomViewer = [FLEXManager sharedManager].customContentTypeViewers[mimeType.lowercaseString];
  354. if (makeCustomViewer) {
  355. UIViewController *viewer = makeCustomViewer(data);
  356. if (viewer) {
  357. return viewer;
  358. }
  359. }
  360. // FIXME (RKO): Don't rely on UTF8 string encoding
  361. UIViewController *detailViewController = nil;
  362. if ([FLEXUtility isValidJSONData:data]) {
  363. NSString *prettyJSON = [FLEXUtility prettyJSONStringFromData:data];
  364. if (prettyJSON.length > 0) {
  365. detailViewController = [[FLEXWebViewController alloc] initWithText:prettyJSON];
  366. }
  367. } else if ([mimeType hasPrefix:@"image/"]) {
  368. UIImage *image = [UIImage imageWithData:data];
  369. detailViewController = [[FLEXImagePreviewViewController alloc] initWithImage:image];
  370. } else if ([mimeType isEqual:@"application/x-plist"]) {
  371. id propertyList = [NSPropertyListSerialization propertyListWithData:data options:0 format:NULL error:NULL];
  372. detailViewController = [[FLEXWebViewController alloc] initWithText:[propertyList description]];
  373. }
  374. // Fall back to trying to show the response as text
  375. if (!detailViewController) {
  376. NSString *text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  377. if (text.length > 0) {
  378. detailViewController = [[FLEXWebViewController alloc] initWithText:text];
  379. }
  380. }
  381. return detailViewController;
  382. }
  383. + (NSData *)postBodyDataForTransaction:(FLEXNetworkTransaction *)transaction
  384. {
  385. NSData *bodyData = transaction.cachedRequestBody;
  386. if (bodyData.length > 0) {
  387. NSString *contentEncoding = [transaction.request valueForHTTPHeaderField:@"Content-Encoding"];
  388. if ([contentEncoding rangeOfString:@"deflate" options:NSCaseInsensitiveSearch].length > 0 || [contentEncoding rangeOfString:@"gzip" options:NSCaseInsensitiveSearch].length > 0) {
  389. bodyData = [FLEXUtility inflatedDataFromCompressedData:bodyData];
  390. }
  391. }
  392. return bodyData;
  393. }
  394. @end