| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #import "HTTPResponseProxy.h"
- #pragma clang diagnostic ignored "-Wdirect-ivar-access"
- @implementation HTTPResponseProxy
- @synthesize response;
- @synthesize status;
- - (NSInteger)status {
- if (status != 0) {
- return status;
- } else if ([response respondsToSelector:@selector(status)]) {
- return [response status];
- }
-
- return 200;
- }
- - (void)setStatus:(NSInteger)statusCode {
- status = statusCode;
- }
- - (NSInteger)customStatus {
- return status;
- }
- // Implement the required HTTPResponse methods
- - (UInt64)contentLength {
- if (response) {
- return [response contentLength];
- } else {
- return 0;
- }
- }
- - (UInt64)offset {
- if (response) {
- return [response offset];
- } else {
- return 0;
- }
- }
- - (void)setOffset:(UInt64)offset {
- if (response) {
- [response setOffset:offset];
- }
- }
- - (NSData *)readDataOfLength:(NSUInteger)length {
- if (response) {
- return [response readDataOfLength:length];
- } else {
- return nil;
- }
- }
- - (BOOL)isDone {
- if (response) {
- return [response isDone];
- } else {
- return YES;
- }
- }
- // Forward all other invocations to the actual response object
- - (void)forwardInvocation:(NSInvocation *)invocation {
- if ([response respondsToSelector:[invocation selector]]) {
- [invocation invokeWithTarget:response];
- } else {
- [super forwardInvocation:invocation];
- }
- }
- - (BOOL)respondsToSelector:(SEL)selector {
- if ([super respondsToSelector:selector])
- return YES;
-
- return [response respondsToSelector:selector];
- }
- @end
|