Don't let AFURLConnectionOperation accept a nil request

Closes #1064
This commit is contained in:
Kyle Fuller 2013-06-14 17:34:35 +01:00
parent 2853215bf3
commit babd06c1f8
2 changed files with 6 additions and 0 deletions

View file

@ -267,6 +267,8 @@ static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) {
#endif #endif
- (id)initWithRequest:(NSURLRequest *)urlRequest { - (id)initWithRequest:(NSURLRequest *)urlRequest {
NSParameterAssert(urlRequest);
self = [super init]; self = [super init];
if (!self) { if (!self) {
return nil; return nil;

View file

@ -37,6 +37,10 @@
#pragma mark - #pragma mark -
- (void)testInitWithNilRequestRaisesException {
expect(^{ (void)[[AFURLConnectionOperation alloc] initWithRequest:nil]; }).to.raiseAny();
}
- (void)testThatAFURLConnectionOperationInvokesWillSendRequestForAuthenticationChallengeBlock { - (void)testThatAFURLConnectionOperationInvokesWillSendRequestForAuthenticationChallengeBlock {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/path" relativeToURL:self.baseURL]]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/path" relativeToURL:self.baseURL]];
AFURLConnectionOperation *operation = [[AFURLConnectionOperation alloc] initWithRequest:request]; AFURLConnectionOperation *operation = [[AFURLConnectionOperation alloc] initWithRequest:request];