Browse files

Remove NSHTTPCookieAdditions, replace with ASINSStringAdditions. See …

…the change log for more info on this change.
  • Loading branch information...
1 parent 194cc40 commit 148d67e18370c6e7190b5aa46936f0c31350f94e @pokeb committed Jun 21, 2009
View
14 Classes/ASIHTTPRequest.m
@@ -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 @@ - (void)main
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 @@ - (BOOL)readResponseHeadersReturningAuthenticationFailure
[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) {
View
8 Classes/NSHTTPCookieAdditions.h → Classes/ASINSStringAdditions.h
@@ -1,5 +1,5 @@
//
-// 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
View
28 Classes/ASINSStringAdditions.m
@@ -0,0 +1,28 @@
+//
+// ASINSStringAdditions.m
+// asi-http-request
+//
+// Created by Ben Copsey on 12/09/2008.
+// Copyright 2008 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASINSStringAdditions.h"
+
+@implementation NSString (CookieValueEncodingAdditions)
+
+- (NSString *)decodedCookieValue
+{
+ 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 *)encodedCookieValue
+{
+ return [self stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+}
+
+@end
+
+
View
28 Classes/NSHTTPCookieAdditions.m
@@ -1,28 +0,0 @@
-//
-// NSHTTPCookieAdditions.m
-// asi-http-request
-//
-// Created by Ben Copsey on 12/09/2008.
-// Copyright 2008 All-Seeing Interactive. All rights reserved.
-//
-
-#import "NSHTTPCookieAdditions.h"
-
-@implementation NSHTTPCookie (ValueEncodingAdditions)
-
-- (NSString *)decodedValue
-{
- NSMutableString *s = [NSMutableString stringWithString:[[self value] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
- //Also swap plus signs for spaces
- [s replaceOccurrencesOfString:@"+" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [s length])];
- return [NSString stringWithString:s];
-}
-
-- (NSString *)encodedValue
-{
- return [[self value] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-}
-
-@end
-
-
View
4 Classes/Tests/ASIHTTPRequestTests.m
@@ -8,7 +8,7 @@
#import "ASIHTTPRequestTests.h"
#import "ASIHTTPRequest.h"
-#import "NSHTTPCookieAdditions.h"
+#import "ASINSStringAdditions.h"
#import "ASINetworkQueue.h"
@@ -320,7 +320,7 @@ - (void)testCookies
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");
View
16 iPhone.xcodeproj/project.pbxproj
@@ -13,7 +13,7 @@
B55B604D0F765A320064029C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60460F765A320064029C /* ASIFormDataRequest.m */; };
B55B604E0F765A320064029C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60480F765A320064029C /* ASIHTTPRequest.m */; };
B55B604F0F765A320064029C /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604A0F765A320064029C /* ASINetworkQueue.m */; };
- B55B60500F765A320064029C /* NSHTTPCookieAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604C0F765A320064029C /* NSHTTPCookieAdditions.m */; };
+ B55B60500F765A320064029C /* ASINSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604C0F765A320064029C /* ASINSStringAdditions.m */; };
B55B60620F765A750064029C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60600F765A750064029C /* main.m */; };
B55B606F0F765A930064029C /* QueueViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60670F765A930064029C /* QueueViewController.m */; };
B55B60700F765A930064029C /* SynchronousViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B606A0F765A930064029C /* SynchronousViewController.m */; };
@@ -29,7 +29,7 @@
B55B60CF0F765BBA0064029C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60460F765A320064029C /* ASIFormDataRequest.m */; };
B55B60D00F765BBD0064029C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60480F765A320064029C /* ASIHTTPRequest.m */; };
B55B60D10F765BC00064029C /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604A0F765A320064029C /* ASINetworkQueue.m */; };
- B55B60D20F765BC30064029C /* NSHTTPCookieAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604C0F765A320064029C /* NSHTTPCookieAdditions.m */; };
+ B55B60D20F765BC30064029C /* ASINSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B604C0F765A320064029C /* ASINSStringAdditions.m */; };
B55B60D30F765BC90064029C /* ASIFormDataRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60530F765A3C0064029C /* ASIFormDataRequestTests.m */; };
B55B60D40F765BCD0064029C /* ASIHTTPRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60550F765A3C0064029C /* ASIHTTPRequestTests.m */; };
B55B60D50F765BD00064029C /* ASINetworkQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B55B60570F765A3C0064029C /* ASINetworkQueueTests.m */; };
@@ -53,8 +53,8 @@
B55B60480F765A320064029C /* ASIHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIHTTPRequest.m; sourceTree = "<group>"; };
B55B60490F765A320064029C /* ASINetworkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASINetworkQueue.h; sourceTree = "<group>"; };
B55B604A0F765A320064029C /* ASINetworkQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASINetworkQueue.m; sourceTree = "<group>"; };
- B55B604B0F765A320064029C /* NSHTTPCookieAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSHTTPCookieAdditions.h; sourceTree = "<group>"; };
- B55B604C0F765A320064029C /* NSHTTPCookieAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSHTTPCookieAdditions.m; sourceTree = "<group>"; };
+ B55B604B0F765A320064029C /* ASINSStringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASINSStringAdditions.h; sourceTree = "<group>"; };
+ B55B604C0F765A320064029C /* ASINSStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASINSStringAdditions.m; sourceTree = "<group>"; };
B55B60520F765A3C0064029C /* ASIFormDataRequestTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIFormDataRequestTests.h; sourceTree = "<group>"; };
B55B60530F765A3C0064029C /* ASIFormDataRequestTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIFormDataRequestTests.m; sourceTree = "<group>"; };
B55B60540F765A3C0064029C /* ASIHTTPRequestTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestTests.h; sourceTree = "<group>"; };
@@ -137,8 +137,8 @@
B55B60480F765A320064029C /* ASIHTTPRequest.m */,
B55B60490F765A320064029C /* ASINetworkQueue.h */,
B55B604A0F765A320064029C /* ASINetworkQueue.m */,
- B55B604B0F765A320064029C /* NSHTTPCookieAdditions.h */,
- B55B604C0F765A320064029C /* NSHTTPCookieAdditions.m */,
+ B55B604B0F765A320064029C /* ASINSStringAdditions.h */,
+ B55B604C0F765A320064029C /* ASINSStringAdditions.m */,
B55B60510F765A3C0064029C /* Tests */,
);
path = Classes;
@@ -328,7 +328,7 @@
B55B604D0F765A320064029C /* ASIFormDataRequest.m in Sources */,
B55B604E0F765A320064029C /* ASIHTTPRequest.m in Sources */,
B55B604F0F765A320064029C /* ASINetworkQueue.m in Sources */,
- B55B60500F765A320064029C /* NSHTTPCookieAdditions.m in Sources */,
+ B55B60500F765A320064029C /* ASINSStringAdditions.m in Sources */,
B55B60620F765A750064029C /* main.m in Sources */,
B55B606F0F765A930064029C /* QueueViewController.m in Sources */,
B55B60700F765A930064029C /* SynchronousViewController.m in Sources */,
@@ -344,7 +344,7 @@
B55B60CF0F765BBA0064029C /* ASIFormDataRequest.m in Sources */,
B55B60D00F765BBD0064029C /* ASIHTTPRequest.m in Sources */,
B55B60D10F765BC00064029C /* ASINetworkQueue.m in Sources */,
- B55B60D20F765BC30064029C /* NSHTTPCookieAdditions.m in Sources */,
+ B55B60D20F765BC30064029C /* ASINSStringAdditions.m in Sources */,
B55B60D30F765BC90064029C /* ASIFormDataRequestTests.m in Sources */,
B55B60D40F765BCD0064029C /* ASIHTTPRequestTests.m in Sources */,
B55B60D50F765BD00064029C /* ASINetworkQueueTests.m in Sources */,

0 comments on commit 148d67e

Please sign in to comment.