Ignite Tools
Shared/Airship/Common/UAHTTPConnection.h
00001 /*
00002  Copyright 2009-2011 Urban Airship Inc. All rights reserved.
00003 
00004  Redistribution and use in source and binary forms, with or without
00005  modification, are permitted provided that the following conditions are met:
00006 
00007  1. Redistributions of source code must retain the above copyright notice, this
00008  list of conditions and the following disclaimer.
00009 
00010  2. Redistributions in binaryform must reproduce the above copyright notice,
00011  this list of conditions and the following disclaimer in the documentation
00012  and/or other materials provided withthe distribution.
00013 
00014  THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR
00015  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00016  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00017  EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00018  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00019  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00021  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00022  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00023  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024  */
00025 
00026 #import <Foundation/Foundation.h>
00027 
00028 
00029 @interface UAHTTPRequest : NSObject {
00030     
00031   @private
00032     NSURL *url;
00033     NSString *HTTPMethod;
00034     NSMutableDictionary *headers;
00035     NSString *username;
00036     NSString *password;
00037     NSMutableData *body;
00038     BOOL compressBody;
00039     id userInfo;
00040 }
00041 @property (readonly, nonatomic) NSURL *url;
00042 @property (copy, nonatomic) NSString *HTTPMethod;
00043 @property (readonly, nonatomic) NSDictionary *headers;
00044 @property (copy, nonatomic) NSString *username;
00045 @property (copy, nonatomic) NSString *password;
00046 @property (retain, nonatomic) NSData *body;
00047 @property (assign, nonatomic) BOOL compressBody;
00048 @property (retain, nonatomic) id userInfo;
00049 
00050 + (UAHTTPRequest *)requestWithURLString:(NSString *)urlString;
00051 - (id)initWithURLString:(NSString *)urlString;
00052 - (void)addRequestHeader:(NSString *)header value:(NSString *)value;
00053 - (void)appendBodyData:(NSData *)data;
00054 
00055 @end
00056 
00057 @protocol UAHTTPConnectionDelegate <NSObject>
00058 @required
00059 - (void)requestDidSucceed:(UAHTTPRequest *)request
00060                response:(NSHTTPURLResponse *)response
00061              responseData:(NSData *)responseData;
00062 - (void)requestDidFail:(UAHTTPRequest *)request;
00063 @end
00064 
00065 
00066 @interface UAHTTPConnection : NSObject {
00067     UAHTTPRequest *request;
00068 
00069     NSURLConnection *urlConnection;
00070     NSHTTPURLResponse *urlResponse;
00071         NSMutableData *responseData;
00072 
00073     id<UAHTTPConnectionDelegate> delegate;
00074 }
00075 @property (assign, nonatomic) id<UAHTTPConnectionDelegate> delegate;
00076 
00077 + (UAHTTPConnection *)connectionWithRequest:(UAHTTPRequest *)httpRequest;
00078 - (id)initWithRequest:(UAHTTPRequest *)httpRequest;
00079 - (BOOL)start;
00080 
00081 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response;
00082 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
00083 - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
00084 - (void)connectionDidFinishLoading:(NSURLConnection *)connection;
00085 
00086 @end
 All Classes Functions Variables Properties