Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-18243] Allow clearing default header #6645

Merged
merged 1 commit into from
Feb 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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