97 lines
4.1 KiB
Objective-C
97 lines
4.1 KiB
Objective-C
// AFURLConnectionOperation.h
|
|
//
|
|
// Copyright (c) 2011 Gowalla (http://gowalla.com/)
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
/**
|
|
Indicates an error occured in AFNetworking.
|
|
|
|
@discussion Error codes for AFNetworkingErrorDomain correspond to codes in NSURLErrorDomain.
|
|
*/
|
|
extern NSString * const AFNetworkingErrorDomain;
|
|
|
|
/**
|
|
Posted when an operation begins executing.
|
|
*/
|
|
extern NSString * const AFNetworkingOperationDidStartNotification;
|
|
|
|
/**
|
|
Posted when an operation finishes.
|
|
*/
|
|
extern NSString * const AFNetworkingOperationDidFinishNotification;
|
|
|
|
|
|
@interface AFURLConnectionOperation : NSOperation {
|
|
@private
|
|
NSSet *_runLoopModes;
|
|
|
|
NSURLConnection *_connection;
|
|
NSURLRequest *_request;
|
|
NSHTTPURLResponse *_response;
|
|
NSError *_error;
|
|
|
|
NSData *_responseData;
|
|
NSInteger _totalBytesRead;
|
|
NSMutableData *_dataAccumulator;
|
|
NSOutputStream *_outputStream;
|
|
}
|
|
|
|
@property (nonatomic, retain) NSSet *runLoopModes;
|
|
|
|
@property (readonly, nonatomic, retain) NSURLRequest *request;
|
|
@property (readonly, nonatomic, retain) NSURLResponse *response;
|
|
@property (readonly, nonatomic, retain) NSError *error;
|
|
|
|
@property (readonly, nonatomic, retain) NSData *responseData;
|
|
@property (readonly, nonatomic, copy) NSString *responseString;
|
|
|
|
@property (nonatomic, retain) NSInputStream *inputStream;
|
|
@property (nonatomic, retain) NSOutputStream *outputStream;
|
|
|
|
/**
|
|
@discussion This is the designated initializer.
|
|
*/
|
|
- (id)initWithRequest:(NSURLRequest *)urlRequest;
|
|
|
|
///---------------------------------
|
|
/// @name Setting Progress Callbacks
|
|
///---------------------------------
|
|
|
|
/**
|
|
Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
|
|
|
|
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times.
|
|
|
|
@see setDownloadProgressBlock
|
|
*/
|
|
- (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))block;
|
|
|
|
/**
|
|
Sets a callback to be called when an undetermined number of bytes have been uploaded to the server.
|
|
|
|
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes read since the last time the upload progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times.
|
|
|
|
@see setUploadProgressBlock
|
|
*/
|
|
- (void)setDownloadProgressBlock:(void (^)(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead))block;
|
|
|
|
@end |