diff ServerComms.mm @ 29:fabb3a5cdfc9

Timed session improvements. Desperate pathetic attempts to send a simple HTTP POST.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 22 Feb 2013 17:41:38 +0000
parents
children c0a6f7c66719
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ServerComms.mm	Fri Feb 22 17:41:38 2013 +0000
@@ -0,0 +1,55 @@
+//
+//  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