MCPcopy Create free account
hub / github.com/grpc/grpc-java / validateName

Method validateName

api/src/main/java/io/grpc/Metadata.java:736–758  ·  view source on GitHub ↗
(String n, boolean pseudo)

Source from the content-addressed store, hash-verified

734 }
735
736 private static String validateName(String n, boolean pseudo) {
737 checkNotNull(n, "name");
738 checkArgument(!n.isEmpty(), "token must have at least 1 tchar");
739 if (n.equals("connection")) {
740 logger.log(
741 Level.WARNING,
742 "Metadata key is 'Connection', which should not be used. That is used by HTTP/1 for "
743 + "connection-specific headers which are not to be forwarded. There is probably an "
744 + "HTTP/1 conversion bug. Simply removing the Connection header is not enough; you "
745 + "should remove all headers it references as well. See RFC 7230 section 6.1",
746 new RuntimeException("exception to show backtrace"));
747 }
748 for (int i = 0; i < n.length(); i++) {
749 char tChar = n.charAt(i);
750 if (pseudo && tChar == ':' && i == 0) {
751 continue;
752 }
753
754 checkArgument(
755 VALID_T_CHARS.get(tChar), "Invalid character '%s' in key name '%s'", tChar, n);
756 }
757 return n;
758 }
759
760 private Key(String name, boolean pseudo, Object marshaller) {
761 this.originalName = checkNotNull(name, "name");

Callers 1

KeyMethod · 0.95

Calls 5

checkNotNullMethod · 0.80
getMethod · 0.65
isEmptyMethod · 0.45
equalsMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected