FLEXNetworkTransaction.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // FLEXNetworkTransaction.h
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 2/8/15.
  6. // Copyright (c) 2020 FLEX Team. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "UIKit/UIKit.h"
  10. typedef NS_ENUM(NSInteger, FLEXNetworkTransactionState) {
  11. FLEXNetworkTransactionStateUnstarted,
  12. FLEXNetworkTransactionStateAwaitingResponse,
  13. FLEXNetworkTransactionStateReceivingData,
  14. FLEXNetworkTransactionStateFinished,
  15. FLEXNetworkTransactionStateFailed
  16. };
  17. @interface FLEXNetworkTransaction : NSObject
  18. @property (nonatomic, copy) NSString *requestID;
  19. @property (nonatomic) NSURLRequest *request;
  20. @property (nonatomic) NSURLResponse *response;
  21. @property (nonatomic, copy) NSString *requestMechanism;
  22. @property (nonatomic) FLEXNetworkTransactionState transactionState;
  23. @property (nonatomic) NSError *error;
  24. @property (nonatomic) NSDate *startTime;
  25. @property (nonatomic) NSTimeInterval latency;
  26. @property (nonatomic) NSTimeInterval duration;
  27. @property (nonatomic) int64_t receivedDataLength;
  28. /// Only applicable for image downloads. A small thumbnail to preview the full response.
  29. @property (nonatomic) UIImage *responseThumbnail;
  30. /// Populated lazily. Handles both normal HTTPBody data and HTTPBodyStreams.
  31. @property (nonatomic, readonly) NSData *cachedRequestBody;
  32. + (NSString *)readableStringFromTransactionState:(FLEXNetworkTransactionState)state;
  33. @end