#!/bin/sh

cat <<HERE
#pragma mark NSURLConnection delegates

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    if (YES) {
        // Display headers for debugging.
        NSHTTPURLResponse *resp = (NSHTTPURLResponse *)response;
        NSLog(@"HTTP response -- (%d) [%@]:\r%@", [resp statusCode], [NSHTTPURLResponse localizedStringForStatusCode:[resp statusCode]], [resp allHeaderFields]);
    }
}


- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
	NSString *dataString = [NSString stringWithUTF8String:[data bytes]];
	NSLog(@"appending %d bytes of new data from connection", [data length]);
	
	// Append the new data to the receivedData.
	//[_data appendData:data];
}


- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
	NSLog(@"did fail with error callback");
}


- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
	if (YES) {
		// Dump data as string for debugging.
		NSString *dataString = [NSString stringWithUTF8String:[_data bytes]];
		NSLog(@"Request succeeded. Received %d bytes of data:\r\r%@", [_data length], dataString);
	}
}


- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
	NSLog(@"did receive auth challenge");
}	
HERE
