Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // LBCHTTPPostBody.h
- // LBCCore
- //
- // Created by Jeremy Foo on 22/5/12.
- // Copyright (c) 2012 BOB FTW PTE LTD. All rights reserved.
- //
- // 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>
- // result is either a stream file NSURL or a NSData
- typedef void (^LBCHTTPPostBodyGenerationCompletionHandler)(BOOL isStreamFile, NSString *contentType, NSString *contentLength, id result, NSError *error);
- typedef enum {
- LBCHTTPPostBodyNoSuchStreamFileError,
- LBCHTTPPostBodyWrongURLPathSpecifiedError
- } LBCHTTPPostBodyErrorStatus;
- extern NSString *const LBCHTTPPostBodyErrorDomain;
- @interface LBCHTTPPostBody : NSObject <NSStreamDelegate, NSCoding>
- @property (readonly) NSMutableDictionary *parameters;
- +(void)performStreamGenerationOfParamters:(NSDictionary *)params toPath:(NSURL *)path completion:(LBCHTTPPostBodyGenerationCompletionHandler)completion;
- +(void)performAutomaticHTTPBodyGenerationOfParameters:(NSDictionary *)params completion:(LBCHTTPPostBodyGenerationCompletionHandler)completion;
- -(id)initWithHTTPParameters:(NSDictionary *)params;
- -(void)performAutomatic:(BOOL)automatic HTTPBodyGenerationWithCompletion:(LBCHTTPPostBodyGenerationCompletionHandler)completion;
- -(void)performStreamGenerationToPath:(NSURL *)path completion:(LBCHTTPPostBodyGenerationCompletionHandler)completion;
- // HTTPBody Specific Methods
- +(BOOL)isExistingFileURLForObject:(id)obj;
- +(BOOL)needMultiPartForParameters:(NSDictionary *)params hasExternalFile:(BOOL *)externalFile;
- // NSData Convinence Methods
- +(NSData *)octetStreamHeaderForName:(NSString *)name filename:(NSString *)filename;
- +(NSData *)octetStreamFooter;
- +(void)appendData:(NSMutableData *)data key:(NSString *)key value:(NSString *)value;
- +(void)appendData:(NSMutableData *)data key:(NSString *)key data:(NSData *)dataValue;
- +(NSInteger)appendOutputStream:(NSOutputStream *)stream key:(NSString *)key value:(NSString *)value;
- +(NSInteger)appendOutputStream:(NSOutputStream *)stream key:(NSString *)key data:(NSData *)dataValue;
- // String Utilities
- +(NSString *)hashForData:(NSData *)data;
- +(NSString *)urlEncodedStringFromParams:(NSDictionary *)params;
- +(NSString *)escapeString:(NSString *)str;
- +(NSString *)escapeString:(NSString *)str withEscapees:(NSString *)escapees;
- +(NSString *)multipartBoundary;
- +(NSString *)contentTypeForMultipart;
- +(NSURL *)fileURLForTemporaryStreamFile;
- @end
Add Comment
Please, Sign In to add comment