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

The following examples show how to use io.netty.util.AsciiString#array() . 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 5 votes vote down vote up
protected AsciiString validateName(AsciiString str) {
  int offset = str.arrayOffset();
  int length = str.length();
  final byte[] data = str.array();
  for (int i = offset; i < offset + length; i++) {
    if (isUpperCase(data[i])) {
      PlatformDependent.throwException(connectionError(PROTOCOL_ERROR,
          "invalid header name '%s'", str));
    }
  }
  return str;
}
 
Example 2
Source File: Utils.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
private static byte[] bytes(CharSequence seq) {
  if (seq instanceof AsciiString) {
    // Fast path - sometimes copy.
    AsciiString str = (AsciiString) seq;
    return str.isEntireArrayUsed() ? str.array() : str.toByteArray();
  }
  // Slow path - copy.
  return seq.toString().getBytes(UTF_8);
}
 
Example 3
Source File: GrpcHttp2HeadersUtils.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
protected AsciiString validateName(AsciiString str) {
  int offset = str.arrayOffset();
  int length = str.length();
  final byte[] data = str.array();
  for (int i = offset; i < offset + length; i++) {
    if (isUpperCase(data[i])) {
      PlatformDependent.throwException(connectionError(PROTOCOL_ERROR,
          "invalid header name '%s'", str));
    }
  }
  return str;
}
 
Example 4
Source File: Utils.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
private static byte[] bytes(CharSequence seq) {
  if (seq instanceof AsciiString) {
    // Fast path - sometimes copy.
    AsciiString str = (AsciiString) seq;
    return str.isEntireArrayUsed() ? str.array() : str.toByteArray();
  }
  // Slow path - copy.
  return seq.toString().getBytes(UTF_8);
}
 
Example 5
Source File: GrpcHttp2HeadersUtils.java    From grpc-nebula-java with Apache License 2.0 4 votes vote down vote up
protected static byte[] bytes(AsciiString str) {
  return str.isEntireArrayUsed() ? str.array() : str.toByteArray();
}
 
Example 6
Source File: GrpcHttp2HeadersUtils.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
protected static byte[] bytes(AsciiString str) {
  return str.isEntireArrayUsed() ? str.array() : str.toByteArray();
}