FLEXNetworkRecorder.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // Notifications posted when the record is updated
  10. extern NSString *const kFLEXNetworkRecorderNewTransactionNotification;
  11. extern NSString *const kFLEXNetworkRecorderTransactionUpdatedNotification;
  12. extern NSString *const kFLEXNetworkRecorderUserInfoTransactionKey;
  13. @class FLEXNetworkTransaction;
  14. @interface FLEXNetworkRecorder : NSObject
  15. /// In general, it only makes sense to have one recorder for the entire application.
  16. + (instancetype)defaultRecorder;
  17. // Accessing recorded network activity
  18. /// Array of FLEXNetworkTransaction objects ordered by start time with the newest first.
  19. - (NSArray *)networkTransactions;
  20. /// The full response data IFF it hasn't been purged due to memory pressure.
  21. - (NSData *)cachedResponseBodyForTransaction:(FLEXNetworkTransaction *)transaction;
  22. // Recording network activity
  23. /// Call when app is about to send HTTP request.
  24. - (void)recordRequestWillBeSentWithRequestId:(NSString *)requestId request:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse;
  25. /// Call when HTTP response is available.
  26. - (void)recordResponseReceivedWithRequestId:(NSString *)requestId response:(NSURLResponse *)response;
  27. /// Call when data chunk is received over the network.
  28. - (void)recordDataReceivedWithRequestId:(NSString *)requestId dataLength:(int64_t)dataLength;
  29. /// Call when HTTP request has finished loading.
  30. - (void)recordLoadingFinishedWithRequestId:(NSString *)requestId responseBody:(NSData *)responseBody;
  31. /// Call when HTTP request has failed to load.
  32. - (void)recordLoadingFailedWithRequestId:(NSString *)requestId error:(NSError *)error;
  33. @end