Cocoa Thrift binding patches from Andrew McGeachie

Summary: Latest updates to the Cocoa bindings


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665354 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cocoa/src/transport/THTTPClient.m b/lib/cocoa/src/transport/THTTPClient.m
index 45c0b80..2e31a98 100644
--- a/lib/cocoa/src/transport/THTTPClient.m
+++ b/lib/cocoa/src/transport/THTTPClient.m
@@ -3,11 +3,13 @@
 
 @implementation THTTPClient
 
-- (id) initWithURL: (NSURL *) aURL
-{
-  self = [super init];
-  mURL = [aURL retain];
 
+- (void) setupRequest
+{
+  if (mRequest != nil) {
+    [mRequest release];
+  }
+  
   // set up our request object that we'll use for each request
   mRequest = [[NSMutableURLRequest alloc] initWithURL: mURL];
   [mRequest setHTTPMethod: @"POST"];
@@ -15,6 +17,15 @@
   [mRequest setValue: @"application/x-thrift" forHTTPHeaderField: @"Accept"];
   [mRequest setValue: @"Cocoa/THTTPClient" forHTTPHeaderField: @"User-Agent"];
   [mRequest setCachePolicy: NSURLRequestReloadIgnoringCacheData];
+}
+
+
+- (id) initWithURL: (NSURL *) aURL
+{
+  self = [super init];
+  mURL = [aURL retain];
+
+  [self setupRequest];
 
   // create our request data buffer
   mRequestData = [[NSMutableData alloc] initWithCapacity: 1024];
@@ -34,6 +45,16 @@
 }
 
 
+- (void) setURL: (NSURL *) aURL
+{
+  [aURL retain];
+  [mURL release];
+  mURL = aURL;
+  
+  [self setupRequest];
+}
+
+
 - (void) dealloc
 {
   [mURL release];