replace more equalsIgnoreCase() calls

This commit is contained in:
zzz
2011-11-28 22:55:10 +00:00
parent 8619fd2c05
commit 6b811b36b9
17 changed files with 61 additions and 43 deletions

View File

@ -16,6 +16,7 @@ import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.Locale;
import java.util.concurrent.RejectedExecutionException;
import net.i2p.I2PAppContext;
@ -177,23 +178,24 @@ class HTTPResponseOutputStream extends FilterOutputStream {
if (_log.shouldLog(Log.INFO))
_log.info("Response header [" + key + "] = [" + val + "]");
if ("Connection".equalsIgnoreCase(key)) {
String lcKey = key.toLowerCase(Locale.US);
if ("connection".equals(lcKey)) {
out.write("Connection: close\r\n".getBytes());
connectionSent = true;
} else if ("Proxy-Connection".equalsIgnoreCase(key)) {
} else if ("proxy-connection".equals(lcKey)) {
out.write("Proxy-Connection: close\r\n".getBytes());
proxyConnectionSent = true;
} else if ( ("Content-encoding".equalsIgnoreCase(key)) && ("x-i2p-gzip".equalsIgnoreCase(val)) ) {
} else if ("content-encoding".equals(lcKey) && "x-i2p-gzip".equals(val.toLowerCase(Locale.US))) {
_gzip = true;
} else if ("Proxy-Authenticate".equalsIgnoreCase(key)) {
} else if ("proxy-authenticate".equals(lcKey)) {
// filter this hop-by-hop header; outproxy authentication must be configured in I2PTunnelHTTPClient
} else {
if ("Content-Length".equalsIgnoreCase(key)) {
if ("content-length".equals(lcKey)) {
// save for compress decision on server side
try {
_dataExpected = Long.parseLong(val);
} catch (NumberFormatException nfe) {}
} else if ("Content-Type".equalsIgnoreCase(key)) {
} else if ("content-type".equals(lcKey)) {
// save for compress decision on server side
_contentType = val;
}

View File

@ -262,7 +262,7 @@ public class I2PTunnelConnectClient extends I2PTunnelHTTPClientBase implements R
}
}
if (destination == null || !"CONNECT".equalsIgnoreCase(method)) {
if (destination == null || method == null || !"CONNECT".equals(method.toUpperCase(Locale.US))) {
writeErrorMessage(ERR_BAD_PROTOCOL, out);
s.close();
return;

View File

@ -758,7 +758,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
if (method == null || destination == null) {
//l.log("No HTTP method found in the request.");
if (out != null) {
if ("http://".equalsIgnoreCase(protocol))
if (protocol != null && "http://".equals(protocol.toLowerCase(Locale.US)))
out.write(getErrorPage("denied", ERR_REQUEST_DENIED));
else
out.write(getErrorPage("protocol", ERR_BAD_PROTOCOL));
@ -1188,7 +1188,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn
}
}
****/
return protocol.equalsIgnoreCase("http://");
return protocol.toLowerCase(Locale.US).equals("http://");
}
private final static byte[] ERR_404 =

View File

@ -10,6 +10,7 @@ import java.net.Socket;
import java.util.ArrayList;
import java.io.File;
import java.util.List;
import java.util.Locale;
import net.i2p.I2PAppContext;
import net.i2p.client.streaming.I2PSocketManager;
@ -101,7 +102,8 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
// Ref: RFC 2617
// If the socket is an InternalSocket, no auth required.
String authRequired = getTunnel().getClientOptions().getProperty(PROP_AUTH);
if (Boolean.valueOf(authRequired).booleanValue() || "basic".equalsIgnoreCase(authRequired)) {
if (Boolean.valueOf(authRequired).booleanValue() ||
(authRequired != null && "basic".equals(authRequired.toLowerCase(Locale.US)))) {
if (s instanceof InternalSocket) {
if (_log.shouldLog(Log.INFO))
_log.info(getPrefix(requestId) + "Internal access, no auth required");

View File

@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.zip.GZIPOutputStream;
@ -507,16 +508,17 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
else
value = "";
if ("Accept-encoding".equalsIgnoreCase(name))
if ("accept-encoding".equals(name.toLowerCase(Locale.US)))
name = "Accept-encoding";
else if ("X-Accept-encoding".equalsIgnoreCase(name))
else if ("x-accept-encoding".equals(name.toLowerCase(Locale.US)))
name = "X-Accept-encoding";
// For incoming, we remove certain headers to prevent spoofing.
// For outgoing, we remove certain headers to improve anonymity.
boolean skip = false;
String lcName = name.toLowerCase(Locale.US);
for (String skipHeader: skipHeaders) {
if (skipHeader.equalsIgnoreCase(name)) {
if (skipHeader.toLowerCase(Locale.US).equals(lcName)) {
skip = true;
break;
}

View File

@ -6,6 +6,7 @@ import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.util.Locale;
import java.util.Properties;
import net.i2p.client.streaming.I2PSocket;
@ -202,13 +203,13 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
idx++;
try {
command = field[idx++];
command = field[idx++].toUpperCase(Locale.US);
} catch (IndexOutOfBoundsException ioobe) {
// wtf, server sent borked command?
throw new IOException("Dropping defective message: index out of bounds while extracting command.");
}
if ("USER".equalsIgnoreCase(command)) {
if ("USER".equals(command)) {
if (field.length < idx + 4)
throw new IOException("Too few parameters in USER message: " + s);
// USER zzz1 hostname localhost :zzz
@ -221,7 +222,7 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
break;
}
buf.append(s).append("\r\n");
if ("SERVER".equalsIgnoreCase(command))
if ("SERVER".equals(command))
break;
}
//if (_log.shouldLog(Log.DEBUG))

View File

@ -58,7 +58,7 @@ abstract class IRCFilter {
if(field[0].charAt(0)==':')
idx++;
try { command = field[idx++]; }
try { command = field[idx++].toUpperCase(Locale.US); }
catch (IndexOutOfBoundsException ioobe) // wtf, server sent borked command?
{
//_log.warn("Dropping defective message: index out of bounds while extracting command.");
@ -74,9 +74,9 @@ abstract class IRCFilter {
} catch(NumberFormatException nfe){}
if ("PING".equalsIgnoreCase(command))
if ("PING".equals(command))
return "PING 127.0.0.1"; // no way to know what the ircd to i2ptunnel server con is, so localhost works
if ("PONG".equalsIgnoreCase(command)) {
if ("PONG".equals(command)) {
// Turn the received ":irc.freshcoffee.i2p PONG irc.freshcoffee.i2p :127.0.0.1"
// into ":127.0.0.1 PONG 127.0.0.1 " so that the caller can append the client's extra parameter
// though, does 127.0.0.1 work for irc clients connecting remotely? and for all of them? sure would
@ -93,12 +93,12 @@ abstract class IRCFilter {
// Allow all allowedCommands
for(int i=0;i<allowedCommands.length;i++) {
if(allowedCommands[i].equalsIgnoreCase(command))
if(allowedCommands[i].equals(command))
return s;
}
// Allow PRIVMSG, but block CTCP.
if("PRIVMSG".equalsIgnoreCase(command) || "NOTICE".equalsIgnoreCase(command))
if("PRIVMSG".equals(command) || "NOTICE".equals(command))
{
String msg;
msg = field[idx++];

View File

@ -344,7 +344,7 @@ public class ConfigNetHandler extends FormHandler {
if (_sharePct != null) {
String old = _context.router().getConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE);
if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) {
if ( (old == null) || (!old.equals(_sharePct)) ) {
_context.router().setConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE, _sharePct);
addFormNotice(_("Updating bandwidth share percentage"));
updated = true;

View File

@ -32,7 +32,8 @@
// doesn't work for restart or shutdown with no expl. tunnels,
// since the call to ConfigRestartBean.renderStatus() hasn't happened yet...
// So we delay slightly
if ("restart".equalsIgnoreCase(action) || "shutdown".equalsIgnoreCase(action)) {
if (action != null &&
("restart".equals(action.toLowerCase(java.util.Locale.US)) || "shutdown".equals(action.toLowerCase(java.util.Locale.US)))) {
synchronized(this) {
try {
wait(1000);

View File

@ -13,6 +13,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
@ -59,7 +60,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
_log = ctx.logManager().getLog(I2PSessionImpl2.class);
_sendingStates = new HashSet(32);
// default is BestEffort
_noEffort = "none".equalsIgnoreCase(getOptions().getProperty(I2PClient.PROP_RELIABILITY));
_noEffort = "none".equals(getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US));
ctx.statManager().createRateStat("i2cp.sendBestEffortTotalTime", "how long to do the full sendBestEffort call?", "i2cp", new long[] { 10*60*1000 } );
//ctx.statManager().createRateStat("i2cp.sendBestEffortStage0", "first part of sendBestEffort?", "i2cp", new long[] { 10*60*1000 } );

View File

@ -11,6 +11,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import net.i2p.util.Log;
@ -72,7 +73,8 @@ public class Base32 {
}
private static void runApp(String args[]) {
if ("encodestring".equalsIgnoreCase(args[0])) {
String cmd = args[0].toLowerCase(Locale.US);
if ("encodestring".equals(cmd)) {
System.out.println(encode(args[1].getBytes()));
return;
}
@ -85,11 +87,11 @@ public class Base32 {
if (args.length >= 2) {
in = new FileInputStream(args[1]);
}
if ("encode".equalsIgnoreCase(args[0])) {
if ("encode".equals(cmd)) {
encode(in, out);
return;
}
if ("decode".equalsIgnoreCase(args[0])) {
if ("decode".equals(cmd)) {
decode(in, out);
return;
}

View File

@ -6,6 +6,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import net.i2p.util.Log;
@ -178,7 +179,8 @@ public class Base64 {
}
private static void runApp(String args[]) {
if ("encodestring".equalsIgnoreCase(args[0])) {
String cmd = args[0].toLowerCase(Locale.US);
if ("encodestring".equals(cmd)) {
System.out.println(encode(args[1].getBytes()));
return;
}
@ -191,11 +193,11 @@ public class Base64 {
if (args.length >= 2) {
in = new FileInputStream(args[1]);
}
if ("encode".equalsIgnoreCase(args[0])) {
if ("encode".equals(cmd)) {
encode(in, out);
return;
}
if ("decode".equalsIgnoreCase(args[0])) {
if ("decode".equals(cmd)) {
decode(in, out);
return;
}

View File

@ -939,27 +939,28 @@ public class EepGet {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Header line: [" + key + "] = [" + val + "]");
if (key.equalsIgnoreCase("Content-length")) {
key = key.toLowerCase(Locale.US);
if (key.equals("content-length")) {
try {
_bytesRemaining = Long.parseLong(val);
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
}
} else if (key.equalsIgnoreCase("ETag")) {
} else if (key.equals("etag")) {
_etag = val;
} else if (key.equalsIgnoreCase("Last-Modified")) {
} else if (key.equals("last-modified")) {
_lastModified = val;
} else if (key.equalsIgnoreCase("Transfer-encoding")) {
} else if (key.equals("transfer-encoding")) {
_encodingChunked = val.toLowerCase(Locale.US).contains("chunked");
} else if (key.equalsIgnoreCase("Content-encoding")) {
} else if (key.equals("content-encoding")) {
// This is kindof a hack, but if we are downloading a gzip file
// we don't want to transparently gunzip it and save it as a .gz file.
// A query string will also mess this up
if ((!_actualURL.endsWith(".gz")) && (!_actualURL.endsWith(".tgz")))
_isGzippedResponse = val.toLowerCase(Locale.US).contains("gzip");
} else if (key.equalsIgnoreCase("Content-Type")) {
} else if (key.equals("content-type")) {
_contentType=val;
} else if (key.equalsIgnoreCase("Location")) {
} else if (key.equals("location")) {
_redirectLocation=val;
} else {
// ignore the rest

View File

@ -1,5 +1,6 @@
package net.i2p.router;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@ -236,7 +237,8 @@ public class TunnelPoolSettings {
private static final boolean getBoolean(String str, boolean defaultValue) {
if (str == null) return defaultValue;
boolean v = Boolean.valueOf(str).booleanValue() || "YES".equalsIgnoreCase(str);
boolean v = Boolean.valueOf(str).booleanValue() ||
(str != null && "YES".equals(str.toUpperCase(Locale.US)));
return v;
}

View File

@ -15,6 +15,7 @@ import java.net.Socket;
import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@ -192,7 +193,7 @@ class ClientConnectionRunner {
_config = config;
// This is the only option that is interpreted here, not at the tunnel manager
if (config.getOptions() != null)
_dontSendMSM = "none".equalsIgnoreCase(config.getOptions().getProperty(I2PClient.PROP_RELIABILITY));
_dontSendMSM = "none".equals(config.getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US));
// per-destination session key manager to prevent rather easy correlation
if (_sessionKeyManager == null)
_sessionKeyManager = new TransientSessionKeyManager(_context);

View File

@ -12,6 +12,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
@ -202,7 +203,7 @@ public class Reseeder {
// We do this more than once, because
// the first SSL handshake may take a while, and it may take the server
// a while to render the index page.
if (_gotDate < MAX_DATE_SETS && "date".equalsIgnoreCase(key) && _attemptStarted > 0) {
if (_gotDate < MAX_DATE_SETS && "date".equals(key.toLowerCase(Locale.US)) && _attemptStarted > 0) {
long timeRcvd = System.currentTimeMillis();
long serverTime = RFC822Date.parse822Date(val);
if (serverTime > 0) {

View File

@ -317,7 +317,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
// And new "always" setting ignores reachability status, like
// "true" was in 0.7.3
String ohost = newProps.getProperty(NTCPAddress.PROP_HOST);
String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "true");
String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "true").toLowerCase(Locale.US);
String name = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
// hostname config trumps auto config
if (name != null && name.length() > 0)
@ -328,7 +328,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
status = udp.getReachabilityStatus();
if (_log.shouldLog(Log.INFO))
_log.info("old: " + ohost + " config: " + name + " auto: " + enabled + " status: " + status);
if (enabled.equalsIgnoreCase("always") ||
if (enabled.equals("always") ||
(Boolean.valueOf(enabled).booleanValue() && status == STATUS_OK)) {
String nhost = UDPProps.getProperty(UDPAddress.PROP_HOST);
if (_log.shouldLog(Log.INFO))
@ -339,7 +339,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
newProps.setProperty(NTCPAddress.PROP_HOST, nhost);
changed = true;
}
} else if (enabled.equalsIgnoreCase("false") &&
} else if (enabled.equals("false") &&
name != null && name.length() > 0 &&
!name.equals(ohost) &&
nport != null) {