Java Code Examples for io.netty.util.AsciiString#indexOf()
The following examples show how to use
io.netty.util.AsciiString#indexOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrpcHttp2HeadersUtils.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@SuppressWarnings("BetaApi") // BaseEncoding is stable in Guava 20.0 protected Http2Headers add(AsciiString name, AsciiString value) { byte[] nameBytes = bytes(name); byte[] valueBytes; if (!name.endsWith(binaryHeaderSuffix)) { valueBytes = bytes(value); addHeader(value, nameBytes, valueBytes); return this; } int startPos = 0; int endPos = -1; while (endPos < value.length()) { int indexOfComma = value.indexOf(',', startPos); endPos = indexOfComma == AsciiString.INDEX_NOT_FOUND ? value.length() : indexOfComma; AsciiString curVal = value.subSequence(startPos, endPos, false); valueBytes = BaseEncoding.base64().decode(curVal); startPos = indexOfComma + 1; addHeader(curVal, nameBytes, valueBytes); } return this; }
Example 2
Source File: ArmeriaHttpUtil.java From armeria with Apache License 2.0 | 6 votes |
/** * Filter the {@link HttpHeaderNames#TE} header according to the * <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.2">special rules in the HTTP/2 RFC</a>. * * @param entry the entry whose name is {@link HttpHeaderNames#TE}. * @param out the resulting HTTP/2 headers. */ private static void toHttp2HeadersFilterTE(Entry<CharSequence, CharSequence> entry, HttpHeadersBuilder out) { if (AsciiString.indexOf(entry.getValue(), ',', 0) == -1) { if (AsciiString.contentEqualsIgnoreCase(AsciiString.trim(entry.getValue()), HttpHeaderValues.TRAILERS)) { out.add(HttpHeaderNames.TE, HttpHeaderValues.TRAILERS.toString()); } } else { final List<CharSequence> teValues = StringUtil.unescapeCsvFields(entry.getValue()); for (CharSequence teValue : teValues) { if (AsciiString.contentEqualsIgnoreCase(AsciiString.trim(teValue), HttpHeaderValues.TRAILERS)) { out.add(HttpHeaderNames.TE, HttpHeaderValues.TRAILERS.toString()); break; } } } }
Example 3
Source File: GrpcHttp2HeadersUtils.java From grpc-java with Apache License 2.0 | 6 votes |
protected Http2Headers add(AsciiString name, AsciiString value) { byte[] nameBytes = bytes(name); byte[] valueBytes; if (!name.endsWith(binaryHeaderSuffix)) { valueBytes = bytes(value); addHeader(value, nameBytes, valueBytes); return this; } int startPos = 0; int endPos = -1; while (endPos < value.length()) { int indexOfComma = value.indexOf(',', startPos); endPos = indexOfComma == AsciiString.INDEX_NOT_FOUND ? value.length() : indexOfComma; AsciiString curVal = value.subSequence(startPos, endPos, false); valueBytes = BaseEncoding.base64().decode(curVal); startPos = indexOfComma + 1; addHeader(curVal, nameBytes, valueBytes); } return this; }
Example 4
Source File: HttpHeaders.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
private static boolean containsCommaSeparatedTrimmed(CharSequence rawNext, CharSequence expected, boolean ignoreCase) { int begin = 0; int end; if (ignoreCase) { if ((end = AsciiString.indexOf(rawNext, ',', begin)) == -1) { if (contentEqualsIgnoreCase(trim(rawNext), expected)) { return true; } } else { do { if (contentEqualsIgnoreCase(trim(rawNext.subSequence(begin, end)), expected)) { return true; } begin = end + 1; } while ((end = AsciiString.indexOf(rawNext, ',', begin)) != -1); if (begin < rawNext.length()) { if (contentEqualsIgnoreCase(trim(rawNext.subSequence(begin, rawNext.length())), expected)) { return true; } } } } else { if ((end = AsciiString.indexOf(rawNext, ',', begin)) == -1) { if (contentEquals(trim(rawNext), expected)) { return true; } } else { do { if (contentEquals(trim(rawNext.subSequence(begin, end)), expected)) { return true; } begin = end + 1; } while ((end = AsciiString.indexOf(rawNext, ',', begin)) != -1); if (begin < rawNext.length()) { if (contentEquals(trim(rawNext.subSequence(begin, rawNext.length())), expected)) { return true; } } } } return false; }