/** * Returns true if {@code fieldName} is content specific and therefore should always be used * from cached headers. */ static boolean isContentSpecificHeader(String fieldName) { return "Content-Length".equalsIgnoreCase(fieldName) || "Content-Encoding".equalsIgnoreCase(fieldName) || "Content-Type".equalsIgnoreCase(fieldName); } }
/** * Determine if the HTTP method is supported by browsers (i.e. GET or POST). */ protected boolean isMethodBrowserSupported(String method) { return ("get".equalsIgnoreCase(method) || "post".equalsIgnoreCase(method)); }
/** * Return {@code true} if the {@link #setSecure secure} flag has been set * to {@code true} or if the {@link #getScheme scheme} is {@code https}. * @see javax.servlet.ServletRequest#isSecure() */ @Override public boolean isSecure() { return (this.secure || HTTPS.equalsIgnoreCase(this.scheme)); }
private boolean isDotDot(String input) { return input.equals("..") || input.equalsIgnoreCase("%2e.") || input.equalsIgnoreCase(".%2e") || input.equalsIgnoreCase("%2e%2e"); }
private static @Nullable String get(String[] namesAndValues, String name) { for (int i = namesAndValues.length - 2; i >= 0; i -= 2) { if (name.equalsIgnoreCase(namesAndValues[i])) { return namesAndValues[i + 1]; } } return null; }
public Builder scheme(String scheme) { if (scheme == null) { throw new NullPointerException("scheme == null"); } else if (scheme.equalsIgnoreCase("http")) { this.scheme = "http"; } else if (scheme.equalsIgnoreCase("https")) { this.scheme = "https"; } else { throw new IllegalArgumentException("unexpected scheme: " + scheme); } return this; }
public PathExtensionPredicate(String extension) { Assert.notNull(extension, "Extension must not be null"); this.extensionPredicate = s -> { boolean match = extension.equalsIgnoreCase(s); traceMatch("Extension", extension, s, match); return match; }; this.extension = extension; }
private static int getPort(URI uri) { int port = uri.getPort(); if (port == -1) { if ("http".equalsIgnoreCase(uri.getScheme())) { port = 80; } else if ("https".equalsIgnoreCase(uri.getScheme())) { port = 443; } } return port; }
private static boolean bodyHasUnknownEncoding(Headers headers) { String contentEncoding = headers.get("Content-Encoding"); return contentEncoding != null && !contentEncoding.equalsIgnoreCase("identity") && !contentEncoding.equalsIgnoreCase("gzip"); } }
/** Equivalent to {@code build().get(name)}, but potentially faster. */ public @Nullable String get(String name) { for (int i = namesAndValues.size() - 2; i >= 0; i -= 2) { if (name.equalsIgnoreCase(namesAndValues.get(i))) { return namesAndValues.get(i + 1); } } return null; }
public Builder removeAll(String name) { for (int i = 0; i < namesAndValues.size(); i += 2) { if (name.equalsIgnoreCase(namesAndValues.get(i))) { namesAndValues.remove(i); // name namesAndValues.remove(i); // value i -= 2; } } return this; }
void addHeader(String name, String value) { if ("Content-Type".equalsIgnoreCase(name)) { try { contentType = MediaType.get(value); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Malformed content type: " + value, e); } } else { requestBuilder.addHeader(name, value); } }
/** Returns true if {@code certificate} matches {@code ipAddress}. */ 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))) { return true; } } return false; }
@Nullable public Subscription getSubscription(String subscriptionId) { for (Map.Entry<String, Set<DefaultSubscriptionRegistry.Subscription>> destinationEntry : this.destinationLookup.entrySet()) { for (Subscription sub : destinationEntry.getValue()) { if (sub.getId().equalsIgnoreCase(subscriptionId)) { return sub; } } } return null; }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (other == null || getClass() != other.getClass()) { return false; } AbstractNameValueExpression<?> that = (AbstractNameValueExpression<?>) other; return ((isCaseSensitiveName() ? this.name.equals(that.name) : this.name.equalsIgnoreCase(that.name)) && ObjectUtils.nullSafeEquals(this.value, that.value) && this.isNegated == that.isNegated); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof HttpCookie)) { return false; } HttpCookie otherCookie = (HttpCookie) other; return (this.name.equalsIgnoreCase(otherCookie.getName())); }
private boolean isMultiple() throws JspException { Object multiple = getMultiple(); if (multiple != null) { String stringValue = multiple.toString(); return ("multiple".equalsIgnoreCase(stringValue) || Boolean.parseBoolean(stringValue)); } return forceMultiple(); }
private boolean peekIdentifierToken(String identifierString) { Token t = peekToken(); if (t == null) { return false; } return (t.kind == TokenKind.IDENTIFIER && identifierString.equalsIgnoreCase(t.stringValue())); }
@Override public Sink createRequestBody(Request request, long contentLength) { if ("chunked".equalsIgnoreCase(request.header("Transfer-Encoding"))) { // Stream a request body of unknown length. return newChunkedSink(); } if (contentLength != -1) { // Stream a request body of a known length. return newFixedLengthSink(contentLength); } throw new IllegalStateException( "Cannot stream a request body without chunked encoding or a known content length!"); }
@GwtIncompatible // String.toUpperCase() has browser semantics public void testEqualsIgnoreCaseUnicodeEquivalence() { // Note that it's possible in future that the JDK's idea to toUpperCase() or equalsIgnoreCase() // may change and break assumptions in this test [*]. This is not a bug in the implementation of // Ascii.equalsIgnoreCase(), but it is a signal that its documentation may need updating as // regards edge cases. // The Unicode point {@code 00df} is the lowercase form of sharp-S (ß), whose uppercase is "SS". assertEquals("PASSWORD", "pa\u00dfword".toUpperCase()); // [*] assertFalse("pa\u00dfword".equalsIgnoreCase("PASSWORD")); // [*] assertFalse(Ascii.equalsIgnoreCase("pa\u00dfword", "PASSWORD")); } }