private static void assertRequestContentEncoding(
            final StubConnection conn,
            final AtomicReference<String> accept) {
        StubRequest req = conn.getRequest();
        String encoding = req.getHeader("Content-encoding");
        String accepted = accept.get();
        if (encoding == null) {
            // We allow lack of encoding even if the CM accepts them
        } else if (accepted == null) {
            fail("Request used content encoding '"
                    + encoding + "' prior to response containing an 'accept' "
                    + " attribute");
        } else {
            // Ensure we used one of the accepted encodings
            boolean found = false;
            for (String token : accepted.split("[,\\s]+")) {
                if (encoding.equals(token)) {
                    found = true;
                }
            }
            if (!found) {
                fail("Content encoding '" + encoding + "' was used when the "
                        + "CM only accepts '" + accepted + "'");
            }
        }

        StubResponse resp = conn.getResponse();
        AbstractBody body = resp.getBody();
        String nowAccepts = body.getAttribute(Attributes.ACCEPT);
        if (nowAccepts != null) {
            accept.set(nowAccepts);
        }
    }