HttpHeadersUtils { public static String getUserAgentValue(Map<String, String> headersMap) { for (Map.Entry<String, String> entry : headersMap.entrySet()) { if ("user-agent".equalsIgnoreCase(entry.getKey())) { return entry.getValue(); } } return null; }  static String getUserAgentValue(Map<String, String> headersMap); static HttpHeaders setHeaders(HttpHeaders headers, Map<String, String> headersMap); static HttpHeaders setHeader(HttpHeaders headers, String key, String value);  }
@Test public void testGetUserAgentValue() { Map<String, String> headersMap = ImmutableMap.of( "Custom-Header", "CustomHeader", "User-Agent", "this is me", "accept", "Accept"); assertEquals("this is me", HttpHeadersUtils.getUserAgentValue(headersMap)); headersMap = ImmutableMap.of("Custom-Header", "CustomHeader", "accept", "Accept"); assertNull(HttpHeadersUtils.getUserAgentValue(headersMap)); }