annotate 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
rev   line source
rt300@29 1 //
rt300@29 2 // ServerComms.m
rt300@29 3 // sonicZoom
rt300@29 4 //
rt300@29 5 // Created by Robert Tubb on 21/02/2013.
rt300@29 6 //
rt300@29 7 //
rt300@29 8
rt300@29 9 #import "ServerComms.h"
rt300@29 10
rt300@29 11 @implementation ServerComms
rt300@29 12 -(void)test{
rt300@29 13 NSLog(@"hi");
rt300@29 14 }
rt300@29 15 -(void)postRequest:(NSString *)msgbody{
rt300@29 16 NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
rt300@29 17 initWithURL:[NSURL
rt300@29 18 URLWithString:msgbody]];
rt300@29 19
rt300@29 20 [request setHTTPMethod:@"POST"];
rt300@29 21 [request setValue:@"text/xml"
rt300@29 22 forHTTPHeaderField:@"Content-type"];
rt300@29 23
rt300@29 24 NSString *xmlString = @"<data><item>Item 1</item><item>Item 2</item></data>";
rt300@29 25
rt300@29 26 [request setValue:[NSString stringWithFormat:@"%d",
rt300@29 27 [xmlString length]]
rt300@29 28 forHTTPHeaderField:@"Content-length"];
rt300@29 29
rt300@29 30 [request setHTTPBody:[xmlString
rt300@29 31 dataUsingEncoding:NSUTF8StringEncoding]];
rt300@29 32
rt300@29 33 [[NSURLConnection alloc]
rt300@29 34 initWithRequest:request
rt300@29 35 delegate:self];
rt300@29 36 }
rt300@29 37
rt300@29 38
rt300@29 39 - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
rt300@29 40 NSLog(@"!!!!!!!!!!!!!!!!!!!!connection error");
rt300@29 41 }
rt300@29 42
rt300@29 43 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
rt300@29 44 NSLog(@"!!!!!!!!!!!!!!!!!!!!didReceiveResponse");
rt300@29 45 }
rt300@29 46
rt300@29 47 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
rt300@29 48 NSLog(@"!!!!!!!!!!!!!!!!!!!!didReceiveData");
rt300@29 49 }
rt300@29 50
rt300@29 51 - (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse{
rt300@29 52
rt300@29 53 }
rt300@29 54
rt300@29 55 @end