Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Closes #34

  • Loading branch information...
commit 1e691582bd7216e1fdddee82b5d96a55dd9f510f 1 parent f55ba76
@stevestreza stevestreza authored
Showing with 31 additions and 1 deletion.
  1. +31 −1 MGTwitterEngine.m
View
32 MGTwitterEngine.m
@@ -67,6 +67,27 @@
#define URL_REQUEST_TIMEOUT 25.0 // Twitter usually fails quickly if it's going to fail at all.
+@interface NSDictionary (MGTwitterEngineExtensions)
+
+-(NSDictionary *)MGTE_dictionaryByRemovingObjectForKey:(NSString *)key;
+
+@end
+
+@implementation NSDictionary (MGTwitterEngineExtensions)
+
+-(NSDictionary *)MGTE_dictionaryByRemovingObjectForKey:(NSString *)key{
+ NSDictionary *result = self;
+ if(key){
+ NSMutableDictionary *newParams = [[self mutableCopy] autorelease];
+ [newParams removeObjectForKey:key];
+ self = [[newParams copy] autorelease];

don't you mean:

result = [[newParams copy] autorelease];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+ return result;
+}
+
+@end
+
+
@interface MGTwitterEngine (PrivateMethods)
@@ -477,7 +498,7 @@ - (NSString *)_sendRequestWithMethod:(NSString *)method
#endif
}
}
-
+
return [self _sendRequest:theRequest withRequestType:requestType responseType:responseType];
}
@@ -575,6 +596,13 @@ - (NSMutableURLRequest *)_baseRequestWithMethod:(NSString *)method
requestType:(MGTwitterRequestType)requestType
queryParameters:(NSDictionary *)params
{
+ NSString *contentType = [params objectForKey:@"Content-Type"];
+ if(contentType){
+ params = [params MGTE_dictionaryByRemovingObjectForKey:@"Content-Type"];
+ }else{
+ contentType = @"application/x-www-form-urlencoded";
+ }
+
// Construct appropriate URL string.
NSString *fullPath = [path stringByAddingPercentEscapesUsingEncoding:NSNonLossyASCIIStringEncoding];
if (params && ![method isEqualToString:HTTP_POST_METHOD]) {
@@ -662,6 +690,8 @@ - (NSMutableURLRequest *)_baseRequestWithMethod:(NSString *)method
[theRequest setValue:_clientName forHTTPHeaderField:@"X-Twitter-Client"];
[theRequest setValue:_clientVersion forHTTPHeaderField:@"X-Twitter-Client-Version"];
[theRequest setValue:_clientURL forHTTPHeaderField:@"X-Twitter-Client-URL"];
+
+ [theRequest setValue:contentType forHTTPHeaderField:@"Content-Type"];
#if SET_AUTHORIZATION_IN_HEADER
if ([self username] && [self password]) {
Please sign in to comment.
Something went wrong with that request. Please try again.