Skip to content

Commit

Permalink
[TIMOB-18243] Allow clearing defaut header
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalduggal committed Feb 17, 2015
1 parent 3cc9a69 commit 947e37d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions iphone/Classes/TiNetworkHTTPClientProxy.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2014 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-2015 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -83,6 +83,13 @@ -(void)open:(id)args
[httpRequest setMethod: method];
[httpRequest setUrl:url];

// twitter specifically disallows X-Requested-With so we only add this normal
// XHR header if not going to twitter. however, other services generally expect
// this header to indicate an XHR request (such as RoR)
if ([[url absoluteString] rangeOfString:@"twitter.com"].location==NSNotFound)
{
[httpRequest addRequestHeader:@"X-Requested-With" value:@"XMLHttpRequest"];
}
if ( (apsConnectionManager != nil) && ([apsConnectionManager willHandleURL:url]) ){
apsConnectionDelegate = [[apsConnectionManager connectionDelegateForUrl:url] retain];
}
Expand Down Expand Up @@ -141,13 +148,6 @@ -(void)send:(id)args
if([self valueForUndefinedKey:@"domain"]) {
// TODO: NTLM
}
// twitter specifically disallows X-Requested-With so we only add this normal
// XHR header if not going to twitter. however, other services generally expect
// this header to indicate an XHR request (such as RoR)
if ([[self valueForUndefinedKey:@"url"] rangeOfString:@"twitter.com"].location==NSNotFound)
{
[httpRequest addRequestHeader:@"X-Requested-With" value:@"XMLHttpRequest"];
}
id file = [self valueForUndefinedKey:@"file"];
if(file) {
NSString *filePath = nil;
Expand Down Expand Up @@ -415,7 +415,10 @@ -(void)setOnredirect:(id)callback
-(void)setRequestHeader:(id)args
{
ENSURE_ARG_COUNT(args,2);
[self ensureClient];
if (httpRequest == nil) {
NSLog(@"[ERROR] No request object found. Did you call open?");
return;
}
NSString *key = [TiUtils stringValue:[args objectAtIndex:0]];
NSString *value = [TiUtils stringValue:[args objectAtIndex:1]];
[httpRequest addRequestHeader:key value:value];
Expand Down

0 comments on commit 947e37d

Please sign in to comment.