Permalink
Browse files

Better error handling on synchronous XML-RPC requests. Thanks to Erik…

… Weiss for pointing this out to me!
  • Loading branch information...
eczarny committed Nov 3, 2011
1 parent 3065f73 commit 1d3aa8224d433dd9891879ade750a759ec3aced9
Showing with 8 additions and 3 deletions.
  1. +8 −3 XMLRPCConnection.m
@@ -79,10 +79,15 @@ - (id)initWithXMLRPCRequest: (XMLRPCRequest *)request delegate: (id<XMLRPCConnec
#pragma mark -
+ (XMLRPCResponse *)sendSynchronousXMLRPCRequest: (XMLRPCRequest *)request error: (NSError **)error {
NSData *data = [[[NSURLConnection sendSynchronousRequest: [request request] returningResponse: nil error: error] retain] autorelease];
NSHTTPURLResponse *response = nil;
NSData *data = [[[NSURLConnection sendSynchronousRequest: [request request] returningResponse: &response error: error] retain] autorelease];
if (data) {
return [[[XMLRPCResponse alloc] initWithData: data] autorelease];
if (response) {
NSInteger statusCode = [response statusCode];
if ((statusCode < 400) && data) {
return [[[XMLRPCResponse alloc] initWithData: data] autorelease];
}
}
return nil;

0 comments on commit 1d3aa82

Please sign in to comment.