Example usage for io.netty.handler.codec.http HttpHeaders iterator

List of usage examples for io.netty.handler.codec.http HttpHeaders iterator

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpHeaders iterator.

Prototype

@Deprecated
@Override
public abstract Iterator<Entry<String, String>> iterator();

Source Link

Usage

From source file:com.github.ambry.rest.PublicAccessLogHandlerTest.java

License:Open Source License

/**
 * Verifies either the expected request headers are found or not found (based on the parameter passed) in the
 * public access log entry/*from  ww  w  .  ja  v  a 2s.com*/
 * @param logEntry the public access log entry
 * @param headers expected headers
 * @param httpMethod HttpMethod type
 * @param expected, true if the headers are expected, false otherwise
 */
private void verifyPublicAccessLogEntryForRequestHeaders(String logEntry, HttpHeaders headers,
        HttpMethod httpMethod, boolean expected) {
    Iterator<Map.Entry<String, String>> itr = headers.iterator();
    while (itr.hasNext()) {
        Map.Entry<String, String> entry = itr.next();
        if (!entry.getKey().startsWith(NOT_LOGGED_HEADER_KEY)
                && !entry.getKey().startsWith(EchoMethodHandler.RESPONSE_HEADER_KEY_PREFIX)) {
            if (httpMethod == HttpMethod.GET && !entry.getKey().equals(HttpHeaders.Names.CONTENT_TYPE)) {
                String subString = "[" + entry.getKey() + "=" + entry.getValue() + "]";
                boolean actual = logEntry.contains(subString);
                if (expected) {
                    Assert.assertTrue("Public Access log entry does not have expected header", actual);
                } else {
                    Assert.assertFalse("Public Access log entry have unexpected header", actual);
                }
            }
        }
    }
}

From source file:org.ebayopensource.scc.filter.NettyRequestProxyFilter.java

License:Apache License

private void debugRequestInfo(HttpObject httpObject, String key) {
    if (m_debugInfo && httpObject instanceof HttpRequest) {
        if (key != null) {
            LOGGER.debug("Cache Key: " + key);
        }//from   ww w. j a v a 2  s . c  o m
        if (httpObject instanceof FullHttpRequest) {
            FullHttpRequest req = (FullHttpRequest) httpObject;
            HttpHeaders headers = req.headers();
            LOGGER.debug("Headers:");
            for (Iterator<Entry<String, String>> it = headers.iterator(); it.hasNext();) {
                Entry<String, String> entry = it.next();
                LOGGER.debug("\t" + entry.getKey() + ":\t" + entry.getValue());
            }
            ByteBuf content = req.content();
            int length = content.readableBytes();
            LOGGER.debug("Content Length: " + length);
            if (length != 0) {
                LOGGER.debug("Content: " + content.toString(Charset.forName("UTF-8")));
            }
        }
    }
}