Skip to content

Commit

Permalink
Merge pull request #4336 from srahim/timob-14012
Browse files Browse the repository at this point in the history
[TIMOB-14012]Android: Providing proper user-agent information.
  • Loading branch information
pingwang2011 committed May 29, 2013
2 parents 1cf61fd + e4646da commit 30296b3
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import org.appcelerator.titanium.util.TiMimeTypeHelper;
import org.appcelerator.titanium.util.TiPlatformHelper;
import org.appcelerator.titanium.util.TiUrl;
import android.os.Build;

import ti.modules.titanium.xml.DocumentProxy;
import ti.modules.titanium.xml.XMLModule;
Expand All @@ -113,7 +114,10 @@ public class TiHTTPClient
private static final String PROPERTY_MAX_BUFFER_SIZE = "ti.android.httpclient.maxbuffersize";
private static final int PROTOCOL_DEFAULT_PORT = -1;
private static final String TITANIUM_ID_HEADER = "X-Titanium-Id";

private static final String TITANIUM_USER_AGENT = "Appcelerator Titanium/" + TiApplication.getInstance().getTiBuildVersion()
+ " ("+ Build.MODEL + "; Android API Level: "
+ Integer.toString(Build.VERSION.SDK_INT) + "; "
+ TiPlatformHelper.getLocale() +";)";
private static final String[] FALLBACK_CHARSETS = {HTTP.UTF_8, HTTP.ISO_8859_1};

// Regular expressions for detecting charset information in response documents (ex: html, xml).
Expand Down Expand Up @@ -871,7 +875,7 @@ public void open(String method, String url)
}
}
setReadyState(READY_STATE_OPENED);
setRequestHeader("User-Agent", (String) proxy.getProperty("userAgent"));
setRequestHeader("User-Agent", TITANIUM_USER_AGENT);
// Causes Auth to Fail with twitter and other size apparently block X- as well
// Ticket #729, ignore twitter for now
if (!hostString.contains("twitter.com")) {
Expand Down

0 comments on commit 30296b3

Please sign in to comment.