@Test public void shouldCanonicalizeHeaders(){ for (String[] v : new String[][] { {"",""}, {"a","A"}, {"fn-ID-","Fn-Id-"}, {"myHeader-VaLue","Myheader-Value"}, {" Not a Header "," Not a Header "}, {"-","-"}, {"--","--"}, {"a-","A-"}, {"-a","-A"} }){ assertThat(Headers.canonicalKey(v[0])).isEqualTo(v[1]); } }
public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); }
Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } }
Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } private  Headers(Map<String, List<String>> headersIn); }
Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } private  Headers(Map<String, List<String>> headersIn); Map getAll(); static String canonicalKey(String key); static Headers fromMap(Map<String, String> headers); static Headers fromMultiHeaderMap(Map<String, List<String>> headers); static Headers emptyHeaders(); Headers setHeaders(Map<String, List<String>> vals); Headers addHeader(String key, String v1, String... vs); Headers setHeader(String key, String v1, String... vs); Headers setHeader(String key, Collection<String> vs); Headers removeHeader(String key); Optional<String> get(String key); Collection<String> keys(); Map<String, List<String>> asMap(); List<String> getAllValues(String key); int hashCode(); boolean equals(Object other); @Override String toString(); }
Headers implements Serializable { public static String canonicalKey(String key) { if (!headerName.matcher(key).matches()) { return key; } String parts[] = key.split("-", -1); for (int i = 0; i < parts.length; i++) { String p = parts[i]; if (p.length() > 0) { parts[i] = p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase(); } } return String.join("-", parts); } private  Headers(Map<String, List<String>> headersIn); Map getAll(); static String canonicalKey(String key); static Headers fromMap(Map<String, String> headers); static Headers fromMultiHeaderMap(Map<String, List<String>> headers); static Headers emptyHeaders(); Headers setHeaders(Map<String, List<String>> vals); Headers addHeader(String key, String v1, String... vs); Headers setHeader(String key, String v1, String... vs); Headers setHeader(String key, Collection<String> vs); Headers removeHeader(String key); Optional<String> get(String key); Collection<String> keys(); Map<String, List<String>> asMap(); List<String> getAllValues(String key); int hashCode(); boolean equals(Object other); @Override String toString();  }