Skip to content
Browse files

Implemented conversion of querystring params to URL-safe equivalent.

  • Loading branch information...
1 parent da71cb3 commit e16d3d883abfa4d434005f0602a78011c9928e0f Owain R Hunt committed Apr 28, 2010
Showing with 12 additions and 13 deletions.
  1. +2 −0 AppController.h
  2. +6 −10 UAGithubEngine.m
  3. +0 −3 UAGithubURLConnection.h
  4. +4 −0 UAGithubURLConnection.m
View
2 AppController.h
@@ -9,8 +9,10 @@
#import <Cocoa/Cocoa.h>
#import "UAGithubEngine.h"
+
@interface AppController : NSObject <UAGithubEngineDelegate> {
UAGithubEngine *githubEngine;
+
}
@end
View
16 UAGithubEngine.m
@@ -67,10 +67,10 @@ - (NSString *)sendRequest:(NSString *)path requestType:(UAGithubRequestType)requ
NSMutableString *querystring = nil;
if (![params isEqual:nil])
{
- querystring = [NSMutableString stringWithFormat:@"&"];
+ querystring = [NSMutableString stringWithCapacity:0];
for (NSString *key in [params allKeys])
{
- [querystring appendFormat:@"%@=%@", key, [params valueForKey:key]];
+ [querystring appendFormat:@"&%@=%@", key, CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[params valueForKey:key], NULL,(CFStringRef)@";/?:@&=$+{}<>,", kCFStringEncodingUTF8)];
}
}
@@ -81,9 +81,7 @@ - (NSString *)sendRequest:(NSString *)path requestType:(UAGithubRequestType)requ
}
NSURL *theURL = [NSURL URLWithString:urlString];
- NSLog(@"Request sent: %@", theURL);
-
- NSURLRequest *urlRequest = [NSURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
+ NSURLRequest *urlRequest = [NSURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
UAGithubURLConnection *connection;
connection = [[UAGithubURLConnection alloc] initWithRequest:urlRequest delegate:self requestType:requestType responseType:responseType];
@@ -159,11 +157,6 @@ - (void)getIssuesForRepository:(NSString *)repositoryPath withRequestType:(UAGit
{
switch (requestType) {
case UAGithubAllIssuesRequest:
- /*
- theData = [[self sendRequest:[NSString stringWithFormat:@"issues/list/%@/open", repositoryPath] withParameters:nil] mutableCopy];
- [theData appendData:[self sendRequest:[NSString stringWithFormat:@"issues/list/%@/closed", repositoryPath] withParameters:nil]];
- */
-
[self sendRequest:[NSString stringWithFormat:@"issues/list/%@/open", repositoryPath] requestType:UAGithubIssuesRequest responseType:UAGithubIssuesResponse withParameters:nil];
[self sendRequest:[NSString stringWithFormat:@"issues/list/%@/closed", repositoryPath] requestType:UAGithubIssuesRequest responseType:UAGithubIssuesResponse withParameters:nil];
break;
@@ -269,12 +262,14 @@ - (void)getUser:(NSString *)user
- (void)getCommitsForBranch:(NSString *)branchPath
{
[self sendRequest:[NSString stringWithFormat:@"commits/list/%@", branchPath] requestType:UAGithubCommitsRequest responseType:UAGithubCommitsResponse withParameters:nil];
+
}
- (void)getCommit:(NSString *)commitPath
{
[self sendRequest:[NSString stringWithFormat:@"commits/show/%@", commitPath] requestType:UAGithubCommitRequest responseType:UAGithubCommitResponse withParameters:nil];
+
}
@@ -310,6 +305,7 @@ - (void)parsingSucceededForConnection:(NSString *)connectionIdentifier ofRespons
default:
break;
}
+ //[NSApp terminate:self];
}
View
3 UAGithubURLConnection.h
@@ -23,10 +23,7 @@
@property (nonatomic, assign) UAGithubResponseType responseType;
@property (nonatomic, retain) NSString *identifier;
-// Initializer
- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate requestType:(UAGithubRequestType)reqType responseType:(UAGithubResponseType)respType;
-
-// Data helper methods
- (void)resetDataLength;
- (void)appendData:(NSData *)newData;
View
4 UAGithubURLConnection.m
@@ -23,18 +23,22 @@ - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate requestType:
responseType = respType;
}
+ NSLog(@"New connection: %@, %@", request, identifier);
+
return self;
}
- (void)resetDataLength
{
[data setLength:0];
+
}
- (void)appendData:(NSData *)newData
{
[data appendData:newData];
+
}

0 comments on commit e16d3d8

Please sign in to comment.
Something went wrong with that request. Please try again.