Showing
2 changed files
with
6 additions
and
2 deletions
| @@ -372,12 +372,16 @@ | @@ -372,12 +372,16 @@ | ||
| 372 | 372 | ||
| 373 | // Test setting a custom cookie works | 373 | // Test setting a custom cookie works |
| 374 | NSDictionary *cookieProperties = [[[NSMutableDictionary alloc] init] autorelease]; | 374 | NSDictionary *cookieProperties = [[[NSMutableDictionary alloc] init] autorelease]; |
| 375 | - [cookieProperties setValue:@"Test Value" forKey:NSHTTPCookieValue]; | 375 | + |
| 376 | + // We'll add a line break to our cookie value to test it gets correctly encoded | ||
| 377 | + [cookieProperties setValue:[@"Test\r\nValue" encodedCookieValue] forKey:NSHTTPCookieValue]; | ||
| 376 | [cookieProperties setValue:@"ASIHTTPRequestTestCookie" forKey:NSHTTPCookieName]; | 378 | [cookieProperties setValue:@"ASIHTTPRequestTestCookie" forKey:NSHTTPCookieName]; |
| 377 | [cookieProperties setValue:@"allseeing-i.com" forKey:NSHTTPCookieDomain]; | 379 | [cookieProperties setValue:@"allseeing-i.com" forKey:NSHTTPCookieDomain]; |
| 378 | [cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60*4] forKey:NSHTTPCookieExpires]; | 380 | [cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60*4] forKey:NSHTTPCookieExpires]; |
| 379 | [cookieProperties setValue:@"/ASIHTTPRequest/tests" forKey:NSHTTPCookiePath]; | 381 | [cookieProperties setValue:@"/ASIHTTPRequest/tests" forKey:NSHTTPCookiePath]; |
| 380 | cookie = [[[NSHTTPCookie alloc] initWithProperties:cookieProperties] autorelease]; | 382 | cookie = [[[NSHTTPCookie alloc] initWithProperties:cookieProperties] autorelease]; |
| 383 | + | ||
| 384 | + GHAssertNotNil(cookie,@"Failed to create a cookie - cookie value was not correctly encoded?"); | ||
| 381 | 385 | ||
| 382 | url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; | 386 | url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/read_cookie"] autorelease]; |
| 383 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; | 387 | request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; |
| @@ -385,7 +389,7 @@ | @@ -385,7 +389,7 @@ | ||
| 385 | [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; | 389 | [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; |
| 386 | [request start]; | 390 | [request start]; |
| 387 | html = [request responseString]; | 391 | html = [request responseString]; |
| 388 | - success = [html isEqualToString:@"I have 'Test Value' as the value of 'ASIHTTPRequestTestCookie'"]; | 392 | + success = [html isEqualToString:@"I have 'Test\r\nValue' as the value of 'ASIHTTPRequestTestCookie'"]; |
| 389 | GHAssertTrue(success,@"Custom cookie not presented to the server with cookie persistance OFF"); | 393 | GHAssertTrue(success,@"Custom cookie not presented to the server with cookie persistance OFF"); |
| 390 | 394 | ||
| 391 | 395 |
This diff was suppressed by a .gitattributes entry.
-
Please register or login to post a comment