Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaned up use of OAMutableURLRequest's prepare method

  • Loading branch information...
commit 38d2f2f3e09e4de61cb0787e831e756200f1c0da 1 parent f4a1506
Steve Streza authored
Showing with 23 additions and 7 deletions.
  1. +5 −0 .gitignore
  2. +0 −7 MGTwitterEngine.m
  3. +18 −0 MGTwitterHTTPURLConnection.m
View
5 .gitignore
@@ -0,0 +1,5 @@
+*.pbxuser
+*.perspectivev3
+build
+yajl
+OAuthConsumer
View
7 MGTwitterEngine.m
@@ -652,11 +652,6 @@ - (NSMutableURLRequest *)_baseRequestWithMethod:(NSString *)method
}
#endif
- //OAMutableURLRequests need to have prepare called on them
- if([theRequest respondsToSelector:@selector(prepare)]){
- [theRequest prepare];
- }
-
return theRequest;
}
@@ -1963,8 +1958,6 @@ - (NSString *)getXAuthAccessTokenForUsername:(NSString *)username
[OARequestParameter requestParameter:@"x_auth_password" value:password],
nil]];
- [request prepare];
-
// Create a connection using this request, with the default timeout and caching policy,
// and appropriate Twitter request and response types for parsing and error reporting.
MGTwitterHTTPURLConnection *connection;
View
18 MGTwitterHTTPURLConnection.m
@@ -10,6 +10,21 @@
#import "NSString+UUID.h"
+
+@interface NSURLRequest (OAuthExtensions)
+-(void)prepare;
+@end
+
+@implementation NSURLRequest (OAuthExtensions)
+
+-(void)prepare{
+ // do nothing
+}
+
+@end
+
+
+
@implementation MGTwitterHTTPURLConnection
@@ -19,6 +34,9 @@ @implementation MGTwitterHTTPURLConnection
- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate
requestType:(MGTwitterRequestType)requestType responseType:(MGTwitterResponseType)responseType
{
+ // OAuth requests need to have -prepare called on them first. handle that case before the NSURLConnection sends it
+ [request prepare];
+
if ((self = [super initWithRequest:request delegate:delegate])) {
_data = [[NSMutableData alloc] initWithCapacity:0];
_identifier = [[NSString stringWithNewUUID] retain];
Please sign in to comment.
Something went wrong with that request. Please try again.