Ben Copsey

Remove NSHTTPCookieAdditions, replace with ASINSStringAdditions. See the change …

…log for more info on this change.
... ... @@ -11,7 +11,6 @@
// See: http://developer.apple.com/samplecode/ImageClient/listing37.html
#import "ASIHTTPRequest.h"
#import "NSHTTPCookieAdditions.h"
#import <zlib.h>
// We use our own custom run loop mode as CoreAnimation seems to want to hijack our threads otherwise
... ... @@ -345,9 +344,9 @@ static NSError *ASIUnableToCreateRequestError;
NSString *cookieHeader = nil;
for (cookie in cookies) {
if (!cookieHeader) {
cookieHeader = [NSString stringWithFormat: @"%@=%@",[cookie name],[cookie encodedValue]];
cookieHeader = [NSString stringWithFormat: @"%@=%@",[cookie name],[cookie value]];
} else {
cookieHeader = [NSString stringWithFormat: @"%@; %@=%@",cookieHeader,[cookie name],[cookie encodedValue]];
cookieHeader = [NSString stringWithFormat: @"%@; %@=%@",cookieHeader,[cookie name],[cookie value]];
}
}
if (cookieHeader) {
... ... @@ -968,14 +967,7 @@ static NSError *ASIUnableToCreateRequestError;
[self setResponseEncoding:encoding];
// Handle cookies
NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:responseHeaders forURL:url];
NSMutableArray *newCookies = [[[NSMutableArray alloc] init] autorelease];
for (NSHTTPCookie *cookie in cookies) {
NSMutableDictionary *properties = [[[NSMutableDictionary alloc] initWithDictionary:[cookie properties]] autorelease];
[properties setValue:[cookie decodedValue] forKey:NSHTTPCookieValue];
[newCookies addObject:[NSHTTPCookie cookieWithProperties:properties]];
}
NSArray *newCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:responseHeaders forURL:url];
[self setResponseCookies:newCookies];
if (useCookiePersistance) {
... ...
//
// NSHTTPCookieAdditions.h
// ASINSStringAdditions.h
// asi-http-request
//
// Created by Ben Copsey on 12/09/2008.
... ... @@ -8,9 +8,9 @@
#import <Foundation/Foundation.h>
@interface NSHTTPCookie (ValueEncodingAdditions)
@interface NSString (CookieValueEncodingAdditions)
- (NSString *)encodedValue;
- (NSString *)decodedValue;
- (NSString *)encodedCookieValue;
- (NSString *)decodedCookieValue;
@end
... ...
//
// NSHTTPCookieAdditions.m
// ASINSStringAdditions.m
// asi-http-request
//
// Created by Ben Copsey on 12/09/2008.
// Copyright 2008 All-Seeing Interactive. All rights reserved.
//
#import "NSHTTPCookieAdditions.h"
#import "ASINSStringAdditions.h"
@implementation NSHTTPCookie (ValueEncodingAdditions)
@implementation NSString (CookieValueEncodingAdditions)
- (NSString *)decodedValue
- (NSString *)decodedCookieValue
{
NSMutableString *s = [NSMutableString stringWithString:[[self value] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableString *s = [NSMutableString stringWithString:[self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//Also swap plus signs for spaces
[s replaceOccurrencesOfString:@"+" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [s length])];
return [NSString stringWithString:s];
}
- (NSString *)encodedValue
- (NSString *)encodedCookieValue
{
return [[self value] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
return [self stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
@end
... ...
... ... @@ -8,7 +8,7 @@
#import "ASIHTTPRequestTests.h"
#import "ASIHTTPRequest.h"
#import "NSHTTPCookieAdditions.h"
#import "ASINSStringAdditions.h"
#import "ASINetworkQueue.h"
... ... @@ -320,7 +320,7 @@
for (cookie in cookies) {
if ([[cookie name] isEqualToString:@"ASIHTTPRequestTestCookie"]) {
foundCookie = YES;
success = [[cookie decodedValue] isEqualToString:@"This is the value"];
success = [[[cookie value] decodedCookieValue] isEqualToString:@"This is the value"];
GHAssertTrue(success,@"Failed to store the correct value for a cookie");
success = [[cookie domain] isEqualToString:@"allseeing-i.com"];
GHAssertTrue(success,@"Failed to store the correct domain for a cookie");
... ...
This diff was suppressed by a .gitattributes entry.