Skip to content
Browse files

Fix some analyzer warnings, including a nasty memory leak.

  • Loading branch information...
1 parent 708c12f commit 6e1775e0006e404fc86cd7082da9d45409c622e6 @adamjernst committed Oct 17, 2011
Showing with 20 additions and 11 deletions.
  1. +18 −10 AEURLConnection/AEExpect.m
  2. +1 −1 AEURLConnection/AEURLConnection.h
  3. +1 −0 AEURLConnection/AEURLConnection.m
View
28 AEURLConnection/AEExpect.m
@@ -22,17 +22,21 @@ + (NSError *)error:(AEExpectErrorCode)code message:(NSString *)message {
+ (AEURLResponseProcessor)statusCode:(NSIndexSet *)acceptableCodes {
return [[^(NSURLResponse *response, id data, NSError **error){
if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
- *error = [AEExpect error:AEExpectResponseNotHTTPError
- message:@"Response is not HTTP"];
+ if (error) {
+ *error = [AEExpect error:AEExpectResponseNotHTTPError
+ message:@"Response is not HTTP"];
+ }
return nil;
}
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (![acceptableCodes containsIndex:statusCode]) {
- *error = [AEExpect error:AEExpectInvalidStatusCodeError
- message:[NSString stringWithFormat:@"%@ (HTTP status %d)",
- [NSHTTPURLResponse localizedStringForStatusCode:statusCode],
- statusCode]];
+ if (error) {
+ *error = [AEExpect error:AEExpectInvalidStatusCodeError
+ message:[NSString stringWithFormat:@"%@ (HTTP status %d)",
+ [NSHTTPURLResponse localizedStringForStatusCode:statusCode],
+ statusCode]];
+ }
return nil;
}
@@ -49,8 +53,10 @@ + (NSIndexSet *)defaultAcceptableStatusCodes {
+ (AEURLResponseProcessor)contentType:(NSSet *)acceptableTypes {
return [[^(NSURLResponse *response, id data, NSError **error) {
if (![acceptableTypes containsObject:[response MIMEType]]) {
- *error = [AEExpect error:AEExpectInvalidContentTypeError
- message:[NSString stringWithFormat:@"Invalid Content-Type %@", [response MIMEType]]];
+ if (error) {
+ *error = [AEExpect error:AEExpectInvalidContentTypeError
+ message:[NSString stringWithFormat:@"Invalid Content-Type %@", [response MIMEType]]];
+ }
return nil;
}
@@ -64,8 +70,10 @@ + (AEURLResponseProcessor)contentType:(NSSet *)acceptableTypes {
+ (AEURLResponseProcessor)responseClass:(Class)class {
return [[^(NSURLResponse *response, id data, NSError **error) {
if (![data isKindOfClass:class]) {
- *error = [AEExpect error:AEExpectInvalidResponseClassError
- message:[NSString stringWithFormat:@"Invalid response class %@", NSStringFromClass([data class])]];
+ if (error) {
+ *error = [AEExpect error:AEExpectInvalidResponseClassError
+ message:[NSString stringWithFormat:@"Invalid response class %@", NSStringFromClass([data class])]];
+ }
return nil;
}
View
2 AEURLConnection/AEURLConnection.h
@@ -12,7 +12,7 @@
// It is REQUIRED that the block either returns an object and leaves the error
// parameter untouched, or sets an error and returns nil. This is enforced with
// an assertion.
-typedef id (^AEURLResponseProcessor)(NSURLResponse *, NSData *, NSError **);
+typedef id (^AEURLResponseProcessor)(NSURLResponse *, id, NSError **);
@interface AEURLConnection : NSObject
View
1 AEURLConnection/AEURLConnection.m
@@ -148,6 +148,7 @@ - (void)networkThreadStartRequest:(AEURLConnectionRequest *)req {
// stored in |_executingRequests|, start it on the network thread.
[connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[connection start];
+ [connection release];
}
- (AEURLConnectionRequest *)executingRequestForConnection:(NSURLConnection *)connection {

0 comments on commit 6e1775e

Please sign in to comment.
Something went wrong with that request. Please try again.