//
//  ServerComms.m
//  sonicZoom
//
//  Created by Robert Tubb on 21/02/2013.
//
//

#import "ServerComms.h"

@implementation ServerComms
-(void)test{
    NSLog(@"hi");
}
-(void)postRequest:(NSString *)msgbody{
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
                                    initWithURL:[NSURL
                                                 URLWithString:msgbody]];
    
    [request setHTTPMethod:@"POST"];
    [request setValue:@"text/xml"
   forHTTPHeaderField:@"Content-type"];
    
    NSString *xmlString = @"<data><item>Item 1</item><item>Item 2</item></data>";
    
    [request setValue:[NSString stringWithFormat:@"%d",
                       [xmlString length]]
   forHTTPHeaderField:@"Content-length"];
    
    [request setHTTPBody:[xmlString
                          dataUsingEncoding:NSUTF8StringEncoding]];
    
    [[NSURLConnection alloc] 
     initWithRequest:request 
     delegate:self];
}


- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
    NSLog(@"!!!!!!!!!!!!!!!!!!!!connection error");
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
    NSLog(@"!!!!!!!!!!!!!!!!!!!!didReceiveResponse");
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
    NSLog(@"!!!!!!!!!!!!!!!!!!!!didReceiveData");
}

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse{
    
}

@end
