Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge in @theorm's additions to RKRequest, and re-vendor cocoa-oauth …

…from our fork with @theorm's additions applied
  • Loading branch information...
commit 856854a66bb55079aa8cd5aab879c696ebc5a76e 1 parent e8825f1
Christopher Swasey authored
12 Code/Network/RKRequest.m
View
@@ -328,28 +328,28 @@ - (void)addHeadersToRequest {
parameters = [_URL queryParameters];
if (self.method == RKRequestMethodPUT)
- echo = [GCOAuth URLRequestForPath:[_URL path]
+ echo = [GCOAuth URLRequestForPath:[_URL originalPath]
PUTParameters:parameters
scheme:[_URL scheme]
- host:[_URL host]
+ host:[_URL hostAndPort]
consumerKey:self.OAuth1ConsumerKey
consumerSecret:self.OAuth1ConsumerSecret
accessToken:self.OAuth1AccessToken
tokenSecret:self.OAuth1AccessTokenSecret];
else if (self.method == RKRequestMethodPOST)
- echo = [GCOAuth URLRequestForPath:[_URL path]
+ echo = [GCOAuth URLRequestForPath:[_URL originalPath]
POSTParameters:parameters
scheme:[_URL scheme]
- host:[_URL host]
+ host:[_URL hostAndPort]
consumerKey:self.OAuth1ConsumerKey
consumerSecret:self.OAuth1ConsumerSecret
accessToken:self.OAuth1AccessToken
tokenSecret:self.OAuth1AccessTokenSecret];
else
- echo = [GCOAuth URLRequestForPath:[_URL path]
+ echo = [GCOAuth URLRequestForPath:[_URL originalPath]
GETParameters:[_URL queryParameters]
scheme:[_URL scheme]
- host:[_URL host]
+ host:[_URL hostAndPort]
consumerKey:self.OAuth1ConsumerKey
consumerSecret:self.OAuth1ConsumerSecret
accessToken:self.OAuth1AccessToken
13 Vendor/cocoa-oauth/GCOAuth.h
View
@@ -85,7 +85,7 @@
tokenSecret:(NSString *)tokenSecret;
/*
- Creates and returns a URL request that will perform a POST HTTPS operation. All
+ Creates and returns a URL request that will perform a POST HTTP operation. All
data will be sent as form URL encoded. Restrictions on the arguments to this
method are the same as the GET request methods.
*/
@@ -135,10 +135,21 @@
consumerSecret:(NSString *)consumerSecret
accessToken:(NSString *)accessToken
tokenSecret:(NSString *)tokenSecret;
+@end
+@interface NSString (GCOAuthAdditions)
+// better percent escape
+- (NSString *)pcen;
@end
+@interface NSURL (GCOAuthURL)
+
+/*
+ Get host:port from URL unless port is 80 or 443 (http://tools.ietf.org/html/rfc5849#section-3.4.1.2). Otherwis reurn only host.
+ */
+- (NSString *)hostAndPort;
+@end
/*
XAuth example (because you may otherwise be scratching your head):
22 Vendor/cocoa-oauth/GCOAuth.m
View
@@ -86,13 +86,6 @@ + (NSURLRequest *)URLRequestForPath:(NSString *)path
consumerSecret:(NSString *)consumerSecret
accessToken:(NSString *)accessToken
tokenSecret:(NSString *)tokenSecret;
-
-@end
-@interface NSString (GCOAuthAdditions)
-
-// better percent escape
-- (NSString *)pcen;
-
@end
@implementation GCOAuth
@@ -182,8 +175,8 @@ - (NSString *)signatureBase {
NSURL *URL = self.URL;
NSString *URLString = [NSString stringWithFormat:@"%@://%@%@",
[[URL scheme] lowercaseString],
- [[URL host] lowercaseString],
- [[URL path] lowercaseString]];
+ [[URL hostAndPort] lowercaseString],
+ [URL path]];
// create components
NSArray *components = [NSArray arrayWithObjects:
@@ -411,6 +404,17 @@ + (NSURLRequest *)URLRequestForPath:(NSString *)path
}
@end
+
+@implementation NSURL (GCOAuthURL)
+- (NSString *)hostAndPort {
+ if ([self port] != nil && [[self port] intValue] != 80 && [[self port] intValue] != 443) {
+ return [NSString stringWithFormat:@"%@:%@", [self host], [self port]];
+ } else {
+ return [self host];
+ }
+}
+@end
+
@implementation NSString (GCOAuthAdditions)
- (NSString *)pcen {
CFStringRef string = CFURLCreateStringByAddingPercentEscapes(NULL,
Please sign in to comment.
Something went wrong with that request. Please try again.