@Override public boolean equals(CharSequence a, CharSequence b) { return AsciiString.contentEquals(a, b); } };
@Override public boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase) { if (ignoreCase) { for (int i = 0; i < nameValuePairs.length; i += 2) { if (contentEqualsIgnoreCase(nameValuePairs[i], name) && contentEqualsIgnoreCase(nameValuePairs[i + 1], value)) { return true; } } } else { for (int i = 0; i < nameValuePairs.length; i += 2) { if (contentEqualsIgnoreCase(nameValuePairs[i], name) && contentEquals(nameValuePairs[i + 1], value)) { return true; } } } return false; }
@Override public boolean equals(CharSequence a, CharSequence b) { return AsciiString.contentEquals(a, b); } };
if (contentEquals(trim(rawNext), expected)) { return true; if (contentEquals(trim(rawNext.subSequence(begin, end)), expected)) { return true; if (contentEquals(trim(rawNext.subSequence(begin, rawNext.length())), expected)) { return true;
@Override public boolean equals(CharSequence a, CharSequence b) { return AsciiString.contentEquals(a, b); } };
/** * Returns {@code true} if the content of both {@link CharSequence}'s are equals. This only supports 8-bit ASCII. */ public static boolean contentEquals(CharSequence a, CharSequence b) { if (a == null || b == null) { return a == b; } if (a.getClass() == AsciiString.class) { return ((AsciiString) a).contentEquals(b); } if (b.getClass() == AsciiString.class) { return ((AsciiString) b).contentEquals(a); } if (a.length() != b.length()) { return false; } for (int i = 0; i < a.length(); ++i) { if (a.charAt(i) != b.charAt(i)) { return false; } } return true; }
/** * Returns {@code true} if the content of both {@link CharSequence}'s are equals. This only supports 8-bit ASCII. */ public static boolean contentEquals(CharSequence a, CharSequence b) { if (a == null || b == null) { return a == b; } if (a.getClass() == AsciiString.class) { return ((AsciiString) a).contentEquals(b); } if (b.getClass() == AsciiString.class) { return ((AsciiString) b).contentEquals(a); } if (a.length() != b.length()) { return false; } for (int i = 0; i < a.length(); ++i) { if (a.charAt(i) != b.charAt(i)) { return false; } } return true; }
/** * Returns {@code true} if the content of both {@link CharSequence}'s are equals. This only supports 8-bit ASCII. */ public static boolean contentEquals(CharSequence a, CharSequence b) { if (a == null || b == null) { return a == b; } if (a.getClass() == AsciiString.class) { return ((AsciiString) a).contentEquals(b); } if (b.getClass() == AsciiString.class) { return ((AsciiString) b).contentEquals(a); } if (a.length() != b.length()) { return false; } for (int i = 0; i < a.length(); ++i) { if (a.charAt(i) != b.charAt(i)) { return false; } } return true; }
static CharSequence websocketHostValue(URI wsURL) { int port = wsURL.getPort(); if (port == -1) { return wsURL.getHost(); } String host = wsURL.getHost(); if (port == HttpScheme.HTTP.port()) { return HttpScheme.HTTP.name().contentEquals(wsURL.getScheme()) || WebSocketScheme.WS.name().contentEquals(wsURL.getScheme()) ? host : NetUtil.toSocketAddressString(host, port); } if (port == HttpScheme.HTTPS.port()) { return HttpScheme.HTTPS.name().contentEquals(wsURL.getScheme()) || WebSocketScheme.WSS.name().contentEquals(wsURL.getScheme()) ? host : NetUtil.toSocketAddressString(host, port); } // if the port is not standard (80/443) its needed to add the port to the header. // See http://tools.ietf.org/html/rfc6454#section-6.2 return NetUtil.toSocketAddressString(host, port); }
static CharSequence websocketOriginValue(URI wsURL) { String scheme = wsURL.getScheme(); final String schemePrefix; int port = wsURL.getPort(); final int defaultPort; if (WebSocketScheme.WSS.name().contentEquals(scheme) || HttpScheme.HTTPS.name().contentEquals(scheme) || (scheme == null && port == WebSocketScheme.WSS.port())) { schemePrefix = HTTPS_SCHEME_PREFIX; defaultPort = WebSocketScheme.WSS.port(); } else { schemePrefix = HTTP_SCHEME_PREFIX; defaultPort = WebSocketScheme.WS.port(); } // Convert uri-host to lower case (by RFC 6454, chapter 4 "Origin of a URI") String host = wsURL.getHost().toLowerCase(Locale.US); if (port != defaultPort && port != -1) { // if the port is not standard (80/443) its needed to add the port to the header. // See http://tools.ietf.org/html/rfc6454#section-6.2 return schemePrefix + NetUtil.toSocketAddressString(host, port); } return schemePrefix + host; } }
private Attribute getContentDispositionAttribute(String... values) { String name = cleanString(values[0]); String value = values[1]; // Filename can be token, quoted or encoded. See https://tools.ietf.org/html/rfc5987 if (HttpHeaderValues.FILENAME.contentEquals(name)) { // Value is quoted or token. Strip if quoted: int last = value.length() - 1; if (last > 0 && value.charAt(0) == HttpConstants.DOUBLE_QUOTE && value.charAt(last) == HttpConstants.DOUBLE_QUOTE) { value = value.substring(1, last); } } else if (FILENAME_ENCODED.equals(name)) { try { name = HttpHeaderValues.FILENAME.toString(); String[] split = value.split("'", 3); value = QueryStringDecoder.decodeComponent(split[2], Charset.forName(split[0])); } catch (ArrayIndexOutOfBoundsException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); } } else { // otherwise we need to clean the value value = cleanString(value); } return factory.createAttribute(request, name, value); }
@Override public HttpServerUpgradeHandler.UpgradeCodec newUpgradeCodec(CharSequence protocol) { if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) { return new Http2ServerUpgradeCodec(new Http2ChannelHandlerBuilder(serverHandler).build()); } else { return null; } } });
@Override public HttpServerUpgradeHandler.UpgradeCodec newUpgradeCodec(CharSequence protocol) { if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) { return new Http2ServerUpgradeCodec(new Http2ChannelHandlerBuilder(serverHandler).build()); } else { return null; } } });
private void h2cOrHttp1(final ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); HttpServerCodec http1codec = http1Codec(); String baseName = name; baseName = addAfter(p, baseName, "codec", http1codec); baseName = addAfter(p, baseName, "h2upgrade", new HttpServerUpgradeHandler(http1codec, protocol -> { if (!AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) { return null; } return new Http2ServerUpgradeCodec(newHttp2ConnectionHandler(p)); }, maxContentLength)); }
@Override public HttpServerUpgradeHandler.UpgradeCodec newUpgradeCodec(CharSequence protocol) { if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) { return new Http2ServerUpgradeCodec(new Http2Codec(true, new JerseyHttp2ServerHandler(baseUri, container))); } else { return null; } } }));
if (null != status && HttpResponseStatus.CONTINUE.codeAsText().contentEquals(status)) { final FullHttpMessage fullMsg = newFullMessage(id, headers, ctx.alloc()); out.add(fullMsg);
if (HttpHeaderValues.IDENTITY.contentEquals(targetContentEncoding)) {
private void configureHttp1WithUpgrade(ChannelHandlerContext ctx) { final ChannelPipeline p = ctx.pipeline(); final HttpServerCodec http1codec = new HttpServerCodec( config.http1MaxInitialLineLength(), config.http1MaxHeaderSize(), config.http1MaxChunkSize()); String baseName = name; assert baseName != null; baseName = addAfter(p, baseName, http1codec); baseName = addAfter(p, baseName, new HttpServerUpgradeHandler( http1codec, protocol -> { if (!AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) { return null; } return new Http2ServerUpgradeCodec( newHttp2ConnectionHandler(p)); }, UPGRADE_REQUEST_MAX_LENGTH)); addAfter(p, baseName, new Http1RequestDecoder(config, ctx.channel(), SCHEME_HTTP, responseEncoder)); }
if (!HttpMethod.POST.asciiName().contentEquals(headers.get(Http2Headers.PseudoHeaderName.METHOD.value()))) { throw new RejectedNotificationException(RejectionReason.METHOD_NOT_ALLOWED);
.maxContentLength(http2Config.maxContentLength()).build(); HttpServerUpgradeHandler upgradeHandler = new HttpServerUpgradeHandler(sourceCodec, protocol -> AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol) ? new Http2ServerUpgradeCodec(helidonHandler) : null);