CPObjectCPURLConnection
@implementation CPURLConnection : CPObject
An interface to downloading content at a specified URL. Using one of the class methods, you can obtain the data.
Method Summary | |
---|---|
+(CPURLConnection) | connectionWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate Creates a url connection with a delegate to monitor the request progress. |
+(CPData) | sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:(CPURLResponse)aURLResponse error:(CPError)anError Sends a request for the data from a URL. |
+(void) | setClassDelegate:(id)delegate |
-(id) | initWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate |
-(id) | initWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate startImmediately:(BOOL)shouldStartImmediately Default class initializer. |
-(void) | cancel Cancels the current request. |
-(id) | delegate return the delegate. |
-(void) | start Start the connection. |
Delegate Method Summary | |
---|---|
-(void) | connection:(CPURLConnection)connection didFailWithError:(id)error Called when the connection encounters an error. |
-(void) | connection:(CPURLConnection)connection didReceiveResponse:(CPHTTPURLResponse)response Called when the connection receives a response. |
-(void) | connection:(CPURLConnection)connection didReceiveData:(CPString)data Called when the connection has received data. |
-(void) | connectionDidFinishLoading:(CPURLConnection)connection Called when the URL has finished loading. |
-(void) | connectionDidReceiveAuthenticationChallenge:(id)connection This class delegate method allows you to set global behavior for when authentication challenges (401 status codes) are returned. |
Method Detail |
---|
+(CPURLConnection)connectionWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate
aRequest
- contains the URL to obtain data fromaDelegate
- will be sent messages related to the request progressstarted to initiate the request
+(CPData)sendSynchronousRequest:(CPURLRequest)aRequest returningResponse:(CPURLResponse)aURLResponse error:(CPError)anError
aRequest
- contains the URL to request the data fromaURLResponse
- not usedanError
- not usednil
if there was an error
+(void)setClassDelegate:(id)delegate
delegate
-(id)initWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate
aRequest
aDelegate
-(id)initWithRequest:(CPURLRequest)aRequest delegate:(id)aDelegate startImmediately:(BOOL)shouldStartImmediately
aRequest
- contains the URL to contactaDelegate
- will receive progress messagesshouldStartImmediately
- whether the start
method should be called from here-(void)cancel
-(id)delegate
-(void)start
Delegate Method Detail |
---|
-(void)connection:(CPURLConnection)connection didFailWithError:(id)error
connection
- the connection that had an errorerror
- the error, which is either a javascript DOMException or an http
status code (javascript number/CPNumber)-(void)connection:(CPURLConnection)connection didReceiveResponse:(CPHTTPURLResponse)response
connection
- the connection that received a responseresponse
- the received response-(void)connection:(CPURLConnection)connection didReceiveData:(CPString)data
connection
- the connection that received datadata
- the received data-(void)connectionDidFinishLoading:(CPURLConnection)connection
connection
- the connection that finished loading
Class Delegate Method:-(void)connectionDidReceiveAuthenticationChallenge:(id)connection
[connection cancel]; [connection start];
connection
- the connection that received the authentication challenge.Created on Sat Sep 13 14:15:43 PDT 2008