Java Code Examples for io.netty.util.AsciiString#endsWith()

The following examples show how to use io.netty.util.AsciiString#endsWith() . 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 vote down vote up
@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: GrpcHttp2HeadersUtils.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
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 3
Source File: MetadataUtil.java    From armeria with Apache License 2.0 4 votes vote down vote up
private static boolean isBinary(AsciiString name) {
    return name.endsWith(Metadata.BINARY_HEADER_SUFFIX);
}