-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* The object which all requests are routed through. You shouldn't need to use | ||
* this class directly, but instead use HRRestModel which wraps the method | ||
* of this class neatly. | ||
*/ | ||
@interface HRRequestOperation : NSOperation { | ||
NSObject <HRResponseDelegate>*_delegate; | ||
NSURLConnection *_connection; | ||
NSMutableData *_responseData; | ||
NSString *_path; | ||
NSDictionary *_options; | ||
NSTimeInterval _timeout; | ||
HRRequestMethod _requestMethod; | ||
id _formatter; | ||
id _object; | ||
BOOL _isFinished; | ||
BOOL _isExecuting; | ||
BOOL _isCancelled; | ||
} | ||
|
||
/** | ||
* The HRResponseDelegate responsible for handling the success and failure of | ||
* a request. | ||
*/ | ||
@property (nonatomic, readonly, assign) NSObject <HRResponseDelegate>*delegate; | ||
|
||
/** | ||
* Sets the length of time in seconds before a request will timeout. | ||
* This defaults to <tt>30.0</tt>. | ||
*/ | ||
@property (nonatomic, assign) NSTimeInterval timeout; | ||
|
||
/** | ||
* This defaults to HRRequestMethodGet. Valid options are ::HRRequestMethod. | ||
*/ | ||
@property (nonatomic, assign) HRRequestMethod requestMethod; | ||
|
||
/** | ||
* If you provide a relative path here, you must set the baseURL option. | ||
* If given a full url this will overide the baseURL option. | ||
*/ | ||
@property (nonatomic, copy) NSString *path; | ||
|
||
/** | ||
* This needs documented | ||
*/ | ||
@property (nonatomic, retain) NSDictionary *options; | ||
|
||
/** | ||
* Currently, only JSON is supported. | ||
*/ | ||
@property (nonatomic, readonly, retain) id formatter; | ||
|
||
/** | ||
* Returns an HRRequestOperation | ||
*/ | ||
+ (HRRequestOperation *)requestWithMethod:(HRRequestMethod)method path:(NSString*)urlPath options:(NSDictionary*)requestOptions object:(id)obj; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// HRResponseDelegate.h | ||
// HTTPRiot | ||
// | ||
// Created by Justin Palmer on 6/24/09. | ||
// Copyright 2009 LabratRevenge LLC.. All rights reserved. | ||
// | ||
|
||
/** | ||
* Implementing the HRResponseDelegate protocol allows you to handle requests. | ||
*/ | ||
@protocol HRResponseDelegate <NSObject> | ||
@optional | ||
/** | ||
* Called when the resource was succeffully fetched and encoded | ||
* | ||
* @param connection The connection object for the current request | ||
* @param resource The converted objc representation of the response data returned by the server. | ||
* @param object Any custom object you passed in while making the request. | ||
*/ | ||
- (void)restConnection:(NSURLConnection *)connection didReturnResource:(id)resource object:(id)object; | ||
|
||
/** | ||
* Called when the connection fails in situations where the server is not available, etc. | ||
* | ||
* @param connection The connection object for the current request | ||
* @param error The error returned by the connection. | ||
* @param object Any custom object you passed in while making the request. | ||
*/ | ||
- (void)restConnection:(NSURLConnection *)connection didFailWithError:(NSError *)error object:(id)object; | ||
|
||
/** | ||
* Called when the connection receieves any type of response | ||
* | ||
* @param connection The connection object for the current request | ||
* @param response The response object returned by the server. | ||
* @param object Any custom object you passed in while making the request. | ||
*/ | ||
- (void)restConnection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response object:(id)object; | ||
|
||
/** | ||
* Called when the connection receieves a statusCode that isn't a success code. | ||
* | ||
* @param connection The connection object for the current request | ||
* @param error The error returned by the connection. | ||
* @param response The response object returned by the server. | ||
* @param object Any custom object you passed in while making the request. | ||
*/ | ||
- (void)restConnection:(NSURLConnection *)connection didReceiveError:(NSError *)error response:(NSHTTPURLResponse *)response object:(id)object; | ||
|
||
/** | ||
* Called when the HRFormatter recieved an error parsing the response data. | ||
* | ||
* @param connection The connection object for the current request | ||
* @param error The parser error returned by the formatter. | ||
* @param body A string representation of the response body returned by the server. | ||
* @param object Any custom object you passed in while making the request. | ||
*/ | ||
- (void)restConnection:(NSURLConnection *)connection didReceiveParseError:(NSError *)error responseBody:(NSString *)body object:(id)object; | ||
@end |