private byte[] getImage(@Nonnull final String host) {
        final Set<URI> urls = new HashSet<>();

        try {
            // Using a builder to reduce the impact of using user-provided values to generate a URL request.
            urls.add(new URIBuilder().setScheme("https").setHost(host).setPath("favicon.ico").build());
            urls.add(new URIBuilder().setScheme("http").setHost(host).setPath("favicon.ico").build());
        } catch (URISyntaxException e) {
            LOGGER.debug("An exception occurred while trying to obtain an image from: {}", host, e);
            return null;
        }
        // Try to get the favicon from the url using an HTTP connection from the pool
        // that also allows configuring timeout values (e.g. connect and get data)
        final RequestConfig requestConfig = RequestConfig.custom()
            .setConnectTimeout(5000)
            .setSocketTimeout(5000)
            .build();

        for (final URI url : urls) {
            final HttpUriRequest getRequest = RequestBuilder.get(url)
                .setConfig(requestConfig)
                .build();

            try (final CloseableHttpResponse response = client.execute(getRequest)) {
                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                    final byte[] result = EntityUtils.toByteArray(response.getEntity());

                    // Prevent SSRF by checking result (OF-1885)
                    if (!GraphicsUtils.isImage(result)) {
                        LOGGER.info("Ignoring response to an HTTP request that should have returned an image (but returned something else): {}", url);
                        continue;
                    }
                    return result;
                }
            } catch (final IOException ex) {
                LOGGER.debug("An exception occurred while trying to obtain an image from: {}", url, ex);
            }
        }
        return null;
    }
Returns the favicon image bytes of the specified host.

@param host the name of the host to get its favicon.
@return the image bytes found, otherwise null.
xmppserver/src/main/java/org/jivesoftware/util/FaviconServlet.java