Changed usages of string paths to CPURL objects.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-09-14 01:01:05 -07:00
1 parent 20d14d2f81
commit c8ed0f5436
5 files changed
+41 -19

No files matched your search

+2 -2
View File
@@ -73,7 +73,7 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
_callbackParameter = aString;
if (!_callbackParameter && [_request URL].indexOf(CPJSONPCallbackReplacementString) < 0)
if (!_callbackParameter && [[_request URL] absoluteString].indexOf(CPJSONPCallbackReplacementString) < 0)
[CPException raise:CPInvalidArgumentException reason:@"JSONP source specified without callback parameter or CPJSONPCallbackReplacementString in URL."];
if(shouldStartImmediately)
@@ -95,7 +95,7 @@ CPJSONPCallbackReplacementString = @"${JSONP_CALLBACK}";
};
var head = document.getElementsByTagName("head").item(0),
source = [_request URL];
source = [[_request URL] absoluteString];
if (_callbackParameter)
{
+19 -3
View File
@@ -31,6 +31,8 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
{
CPURL _base @accessors(readonly, property=baseURL);
CPString _relative @accessors(readonly, property=relativeString);
CPDictionary _resourceValues;
}
- (id)initWithScheme:(CPString)scheme host:(CPString)host path:(CPString)path
@@ -57,9 +59,13 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
if (!URI_RE.test(URLString))
return nil;
_base = baseURL;
_relative = URLString;
if (self)
{
_base = baseURL;
_relative = URLString;
_resourceValues = [CPDictionary dictionary];
}
return self;
}
@@ -184,6 +190,16 @@ CPURLCustomIconKey = @"CPURLCustomIconKey";
return [self absoluteString];
}
- (id)resourceValueForKey:(CPString)aKey
{
return [_resourceValues objectForKey:aKey];
}
- (id)setResourceValue:(id)anObject forKey:(CPString)aKey
{
[_resourceValues setObject:anObject forKey:aKey];
}
@end
@implementation CPURL (CPCoding)
+14 -13
View File
@@ -106,17 +106,17 @@ var CPURLConnectionDelegate = nil;
{
var request = objj_request_xmlhttp();
request.open([aRequest HTTPMethod], [aRequest URL], NO);
request.open([aRequest HTTPMethod], [[aRequest URL] absoluteString], NO);
var fields = [aRequest allHTTPHeaderFields],
key = nil,
keys = [fields keyEnumerator];
while (key = [keys nextObject])
request.setRequestHeader(key, [fields objectForKey:key]);
request.send([aRequest HTTPBody]);
return [CPData dataWithString:request.responseText];
}
catch (anException)
@@ -154,20 +154,21 @@ var CPURLConnectionDelegate = nil;
_delegate = aDelegate;
_isCanceled = NO;
var path = [_request URL];
var URL = [_request URL],
scheme = [URL scheme];
// Browsers use "file:", Titanium uses "app:"
_isLocalFileConnection = path.indexOf("file:") === 0 ||
((path.indexOf("http:") !== 0 || path.indexOf("https:") !== 0) &&
_isLocalFileConnection = scheme === "file" ||
((scheme !== "http" || scheme !== "https:") &&
window.location &&
(window.location.protocol === "file:" || window.location.protocol === "app:"));
_XMLHTTPRequest = objj_request_xmlhttp();
if (shouldStartImmediately)
[self start];
}
return self;
}
@@ -193,7 +194,7 @@ var CPURLConnectionDelegate = nil;
try
{
_XMLHTTPRequest.open([_request HTTPMethod], [_request URL], YES);
_XMLHTTPRequest.open([_request HTTPMethod], [[_request URL] absoluteString], YES);
_XMLHTTPRequest.onreadystatechange = function() { [self _readyStateDidChange]; }
+5 -1
View File
@@ -62,7 +62,11 @@
if (self)
{
_URL = aURL;
if ([aURL isKindOfClass:[CPString class]])
_URL = [CPURL URLWithString:aURL];
else
_URL = aURL;
_HTTPBody = @"";
_HTTPMethod = @"GET";
_HTTPHeaderFields = [CPDictionary dictionary];
+1
View File
@@ -50,6 +50,7 @@
@import "CPString.j"
@import "CPTimer.j"
@import "CPUndoManager.j"
@import "CPURL.j"
@import "CPURLConnection.j"
@import "CPURLRequest.j"
@import "CPURLResponse.j"