Skip to content

Commit

Permalink
[TIMOB-17175]Updating HTTPClient Library
Browse files Browse the repository at this point in the history
  • Loading branch information
srahim committed Jun 17, 2014
1 parent 86dd060 commit 7224206
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 101 deletions.
Binary file modified iphone/Classes/APSAnalytics/libAPSAnalytics.a
Binary file not shown.
5 changes: 0 additions & 5 deletions iphone/Classes/APSHTTPClient/APSHTTPClient.h
Expand Up @@ -5,10 +5,6 @@
* Please see the LICENSE included with this distribution for details.
*/

#ifndef RELEASE_TO_NIL
#define RELEASE_TO_NIL(x) { if (x!=nil) { [x release]; x = nil; } }
#endif

#ifndef DebugLog
#if defined(DEBUG) || defined(DEVELOPER)
#define DebugLog(...) { NSLog(__VA_ARGS__); }
Expand All @@ -20,5 +16,4 @@
#import "APSHTTPRequest.h"
#import "APSHTTPResponse.h"
#import "APSHTTPPostForm.h"
#import "APSHTTPOperation.h"
#import "APSHTTPHelper.h"
21 changes: 0 additions & 21 deletions iphone/Classes/APSHTTPClient/APSHTTPOperation.h

This file was deleted.

9 changes: 1 addition & 8 deletions iphone/Classes/APSHTTPClient/APSHTTPPostForm.h
Expand Up @@ -8,14 +8,7 @@
#import <Foundation/Foundation.h>

@interface APSHTTPPostForm : NSObject
{
NSMutableDictionary *_requestFormDictionay;
NSMutableArray *_requestFilesArray;
NSMutableDictionary *_headers;
NSMutableData *_postFormData;
NSData *_jsonData;
NSData *_stringData;
}

@property(nonatomic, readonly) NSData *requestData;
@property(nonatomic, readonly) NSDictionary *requestHeaders;
@property(nonatomic, readonly) NSString *contentType;
Expand Down
87 changes: 47 additions & 40 deletions iphone/Classes/APSHTTPClient/APSHTTPRequest.h
Expand Up @@ -7,22 +7,14 @@

#import <Foundation/Foundation.h>

typedef enum {
APSRequestAuthNone = 0,
APSRequestAuthBasic = 1,
APSRequestAuthDigest = 2,
APSRequestAuthChallange = 3
} APSRequestAuth;

typedef enum {
typedef NS_ENUM(NSInteger, APSRequestError) {
APSRequestErrorCancel = 0
} APSRequestError;
};


@class APSHTTPResponse;
@class APSHTTPRequest;
@class APSHTTPPostForm;
@class APSHTTPOperation;

@protocol APSConnectionDelegate <NSURLConnectionDelegate>
@optional
Expand All @@ -35,42 +27,57 @@ typedef enum {
-(void)request:(APSHTTPRequest*)request onError:(APSHTTPResponse*)response;
-(void)request:(APSHTTPRequest*)request onDataStream:(APSHTTPResponse*)response;
-(void)request:(APSHTTPRequest*)request onSendStream:(APSHTTPResponse*)response;
-(void)request:(APSHTTPRequest*)request onReadyStateChage:(APSHTTPResponse*)response;
-(void)request:(APSHTTPRequest*)request onReadyStateChange:(APSHTTPResponse*)response;
-(void)request:(APSHTTPRequest*)request onRedirect:(APSHTTPResponse*)response;

@end

@interface APSHTTPRequest : NSObject<NSURLConnectionDelegate, NSURLConnectionDataDelegate>
{
long long _expectedDownloadResponseLength;
NSURLConnection *_connection;
NSMutableDictionary *_headers;
APSHTTPOperation* _operation;
}
@interface APSHTTPRequest : NSObject

@property(nonatomic, strong, readwrite) NSURL *url;
@property(nonatomic, strong, readwrite) NSString *method;
@property(nonatomic, strong, readwrite) NSString *filePath;
@property(nonatomic, strong, readwrite) NSString *requestUsername;
@property(nonatomic, strong, readwrite) NSString *requestPassword;
@property(nonatomic, strong, readwrite) APSHTTPPostForm *postForm;
@property(nonatomic, strong, readonly ) APSHTTPResponse *response;
@property(nonatomic, weak, readwrite) NSObject<APSHTTPRequestDelegate> *delegate;
@property(nonatomic, weak, readwrite) NSObject<APSConnectionDelegate> *connectionDelegate;
@property(nonatomic, assign, readwrite) NSTimeInterval timeout;
@property(nonatomic, assign, readwrite) BOOL sendDefaultCookies;
@property(nonatomic, assign, readwrite) BOOL redirects;
@property(nonatomic, assign, readwrite) BOOL validatesSecureCertificate;
@property(nonatomic, assign, readwrite) BOOL cancelled;
@property(nonatomic, assign, readwrite) NSURLRequestCachePolicy cachePolicy;

/*!
@discussion Set to YES to block the caller's thread for the duration
of the network call. In this case the queue property is ignored. The
default value is NO.
*/
@property(nonatomic, assign, readwrite) BOOL synchronous;

/*!
@discussion An optional NSOperationQueue for delegate callbacks.
The default value is nil, which means delegate callbakcs occur on
the caller's thread if the synchronous property is NO. If the
synchronous property is YES then this property is ignored.
*/
@property(nonatomic, strong, readwrite) NSOperationQueue *theQueue;

/*!
@discussion An optioanl array of run loop modes for delegate calllbacks
on the run loop of the caller's thread. The default is one element
array containing NSDefaultRunLoopMode. This is an advanced property,
and is ignored if synchronous is YES or theQueue is not nil. It is
the caller's responsibility to keep the thread and the run loop alive.
*/
@property(nonatomic, strong, readwrite) NSArray *runModes;

// Only used in Titanium ImageLoader
@property(nonatomic, strong, readwrite) NSDictionary *userInfo;

@property(nonatomic, readonly) NSMutableURLRequest *request;
@property(nonatomic, retain) NSURL *url;
@property(nonatomic, retain) NSString *method;
@property(nonatomic, retain) NSString *filePath;
@property(nonatomic, retain) NSString *requestUsername;
@property(nonatomic, retain) NSString *requestPassword;
@property(nonatomic, retain) APSHTTPPostForm *postForm;
@property(nonatomic, readonly) APSHTTPResponse* response;
@property(nonatomic, assign) NSObject<APSHTTPRequestDelegate>* delegate;
@property(nonatomic, assign) NSObject<APSConnectionDelegate>* connectionDelegate;
@property(nonatomic) NSTimeInterval timeout;
@property(nonatomic) BOOL sendDefaultCookies;
@property(nonatomic) BOOL redirects;
@property(nonatomic) BOOL synchronous;
@property(nonatomic) BOOL validatesSecureCertificate;
@property(nonatomic) BOOL cancelled;
@property(nonatomic) APSRequestAuth authType;
@property(nonatomic, retain) NSOperationQueue *theQueue;
@property(nonatomic, retain) NSDictionary *userInfo;
-(void)send;
-(void)abort;
-(void)addRequestHeader:(NSString*)key value:(NSString*)value;
-(void)setCachePolicy:(NSURLRequestCachePolicy)cache;
-(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error;
-(NSURLConnection*)connection;
@end
54 changes: 27 additions & 27 deletions iphone/Classes/APSHTTPClient/APSHTTPResponse.h
Expand Up @@ -7,40 +7,40 @@

#import <Foundation/Foundation.h>

typedef enum {
typedef NS_ENUM(NSInteger, APSHTTPResponseState) {
APSHTTPResponseStateUnsent = 0,
APSHTTPResponseStateOpened = 1,
APSHTTPResponseStateHeaders = 2,
APSHTTPResponseStateLoading = 3,
APSHTTPResponseStateDone = 4
} APSHTTPResponseState;
};

@interface APSHTTPResponse : NSObject
{
NSMutableData *_data;
}
@property(nonatomic, readonly) NSURL *url;
@property(nonatomic, readonly) NSInteger status;
@property(nonatomic, readonly) NSDictionary *headers;
@property(nonatomic, readonly) NSString *connectionType;
@property(nonatomic, readonly) NSString *location;
@property(nonatomic) NSStringEncoding encoding;
@property(nonatomic, retain) NSError *error;
@property(nonatomic, retain) NSString *filePath;
@property(nonatomic) float downloadProgress;
@property(nonatomic) float uploadProgress;

@property(nonatomic, readonly) NSData* responseData;
@property(nonatomic, readonly) NSInteger responseLength;
@property(nonatomic, readonly) NSString*responseString;
@property(nonatomic, readonly) NSDictionary*responseDictionary;
@property(nonatomic, readonly) NSArray* responseArray;

@property(nonatomic) BOOL saveToFile;
@property(nonatomic) BOOL connected;
@property(nonatomic) APSHTTPResponseState readyState;

//@property(nonatomic, strong, readonly ) NSURL *url;
@property(nonatomic, strong, readonly ) NSDictionary *headers; // used by TiNetworkHTTPClientProxy, ImageLoader
@property(nonatomic, strong, readonly ) NSString *connectionType; // used by TiNetworkHTTPClientProxy
//@property(nonatomic, assign, readonly ) NSStringEncoding encoding;

@property(nonatomic, strong, readonly ) NSData *responseData; // used by TiNetworkHTTPClientProxy, ImageLoader
@property(nonatomic, strong, readonly ) NSString *responseString; // used by TiNetworkHTTPClientProxy, YahooModule and GeolocationModule
@property(nonatomic, strong, readonly ) NSDictionary *responseDictionary; // used by TiNetworkHTTPClientProxy
@property(nonatomic, strong, readonly ) NSArray *responseArray; // used by TiNetworkHTTPClientProxy
@property(nonatomic, assign, readonly ) BOOL saveToFile; // used by TiNetworkHTTPClientProxy

@property(nonatomic, assign, readonly ) NSInteger status; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, strong, readonly ) NSString *location; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, assign, readonly ) NSInteger responseLength; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, strong, readwrite) NSError *error; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, strong, readwrite) NSString *filePath; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, assign, readwrite) float downloadProgress; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, assign, readwrite) float uploadProgress; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, assign, readwrite) BOOL connected; // should be protocol (used by APSHTTPRequest)
@property(nonatomic, assign, readwrite) APSHTTPResponseState readyState; // should be protocol (used by APSHTTPRequest)

- (void) updateRequestParamaters:(NSURLRequest *)request;
- (void) updateResponseParamaters:(NSURLResponse *)response;


-(void)appendData:(NSData*)data;
-(void)setResponse:(NSURLResponse*) response;
-(void)setRequest:(NSURLRequest*) request;
@end
Binary file modified iphone/Classes/APSHTTPClient/libAPSHTTPClient.a
Binary file not shown.

0 comments on commit 7224206

Please sign in to comment.