-
Notifications
You must be signed in to change notification settings - Fork 294
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
Minor code simplifications #185
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,6 @@ final class OkHostnameVerifier implements HostnameVerifier { | |
private OkHostnameVerifier() { | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure compatibility with Java 1.5 ( |
||
public boolean verify(String host, SSLSession session) { | ||
try { | ||
Certificate[] certificates = session.getPeerCertificates(); | ||
|
@@ -83,8 +82,8 @@ static boolean verifyAsIpAddress(String host) { | |
*/ | ||
private boolean verifyIpAddress(String ipAddress, X509Certificate certificate) { | ||
List<String> altNames = getSubjectAltNames(certificate, ALT_IPA_NAME); | ||
for (int i = 0, size = altNames.size(); i < size; i++) { | ||
if (ipAddress.equalsIgnoreCase(altNames.get(i))) { | ||
for (String altName : altNames) { | ||
if (ipAddress.equalsIgnoreCase(altName)) { | ||
return true; | ||
} | ||
} | ||
|
@@ -98,9 +97,9 @@ private boolean verifyHostName(String hostName, X509Certificate certificate) { | |
hostName = hostName.toLowerCase(Locale.US); | ||
boolean hasDns = false; | ||
List<String> altNames = getSubjectAltNames(certificate, ALT_DNS_NAME); | ||
for (int i = 0, size = altNames.size(); i < size; i++) { | ||
for (String altName : altNames) { | ||
hasDns = true; | ||
if (verifyHostName(hostName, altNames.get(i))) { | ||
if (verifyHostName(hostName, altName)) { | ||
return true; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -745,9 +745,8 @@ private void appendPayloadBinary(StringBuilder builder) | |
return; | ||
} | ||
|
||
for (int i = 0; i < mPayload.length; ++i) | ||
{ | ||
builder.append(String.format("%02X ", (0xFF & mPayload[i]))); | ||
for (byte b : mPayload) { | ||
builder.append(String.format("%02X ", (0xFF & b))); | ||
} | ||
|
||
if (mPayload.length != 0) | ||
|
@@ -1199,15 +1198,17 @@ private static List<WebSocketFrame> split(WebSocketFrame frame, int maxPayloadSi | |
|
||
// Generate the first frame using the existing WebSocketFrame instance. | ||
// Note that the reserved bit 1 and the opcode are untouched. | ||
byte[] payload = Arrays.copyOf(originalPayload, maxPayloadSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
byte[] payload = new byte[maxPayloadSize]; | ||
System.arraycopy(originalPayload, 0, payload, 0, Math.min(originalPayload.length, maxPayloadSize)); | ||
frame.setFin(false).setPayload(payload); | ||
frames.add(frame); | ||
|
||
for (int from = maxPayloadSize; from < originalPayload.length; from += maxPayloadSize) | ||
{ | ||
// Prepare the payload of the next continuation frame. | ||
int to = Math.min(from + maxPayloadSize, originalPayload.length); | ||
payload = Arrays.copyOfRange(originalPayload, from, to); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
assert (to - from) >= 0; | ||
System.arraycopy(originalPayload, from, payload, 0, Math.min(originalPayload.length - from, to - from)); | ||
|
||
// Create a continuation frame. | ||
WebSocketFrame cont = WebSocketFrame.createContinuationFrame(payload); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception at runtime possible otherwise.