Skip to content

Instantly share code, notes, and snippets.

@akfish
Created October 21, 2011 15:30
Show Gist options
  • Save akfish/1304125 to your computer and use it in GitHub Desktop.
Save akfish/1304125 to your computer and use it in GitHub Desktop.
A minor change on Android API Level 2.3.3
HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
String sHeader = httpConnection.getHeaderFieldKey(i);
if (sHeader.equals("content-length")) {
//Unpredictable
//Under the same server setup, the API level before 2.3.3 will return true.
//But not this one
}
if (sHeader.equalsIgnoreCase("content-length")) {
//True
//It seems that in 2.3.3, all header field key are case sensitive.
}
//Summary: Always use equalsIgnoreCase, if letter case is not needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment