FLEXNetworkRecorder.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // FLEXNetworkRecorder.h
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 2/4/15.
  6. // Copyright (c) 2015 Flipboard. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class FLEXNetworkTransaction;
  10. @interface FLEXNetworkRecorder : NSObject
  11. /// In general, it only makes sense to have one recorder for the entire application.
  12. + (instancetype)defaultRecorder;
  13. // Accessing recorded network activity
  14. /// Array of FLEXNetworkTransaction objects ordered by start time with the oldest first.
  15. - (NSArray *)networkTransactions;
  16. /// The full response data IFF it hasn't been purged due to memory pressure.
  17. - (NSData *)cachedResponseBodyForTransaction:(FLEXNetworkTransaction *)transaction;
  18. // Recording network activity
  19. /// Call when app is about to send HTTP request.
  20. - (void)recordRequestWillBeSentWithRequestId:(NSString *)requestId request:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse;
  21. /// Call when HTTP response is available.
  22. - (void)recordResponseReceivedWithRequestId:(NSString *)requestId response:(NSURLResponse *)response;
  23. /// Call when data chunk is received over the network.
  24. - (void)recordDataReceivedWithRequestId:(NSString *)requestId dataLength:(int64_t)dataLength;
  25. /// Call when HTTP request has finished loading.
  26. - (void)recordLoadingFinishedWithRequestId:(NSString *)requestId responseBody:(NSData *)responseBody;
  27. /// Call when HTTP request has failed to load.
  28. - (void)recordLoadingFailedWithRequestId:(NSString *)requestId error:(NSError *)error;
  29. @end