001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.access.pattern;
015
016import java.util.Enumeration;
017
018import ch.qos.logback.access.spi.IAccessEvent;
019import ch.qos.logback.core.CoreConstants;
020
021/**
022 * This class is tied to the <code>fullRequest</code> conversion word.
023 * <p>
024 * It has been removed from the {@link ch.qos.logback.access.PatternLayout}
025 * since it needs further testing before wide use.
026 * <p>
027 * 
028 * @author Ceki G&uuml;lc&uuml;
029 * @author S&eacute;bastien Pennec
030 */
031public class FullRequestConverter extends AccessConverter {
032
033    @Override
034    public String convert(IAccessEvent ae) {
035        StringBuilder buf = new StringBuilder();
036        buf.append(ae.getRequestURL());
037        buf.append(CoreConstants.LINE_SEPARATOR);
038
039        Enumeration<String> headerNames = ae.getRequestHeaderNames();
040        while (headerNames.hasMoreElements()) {
041            String name = headerNames.nextElement();
042            buf.append(name);
043            buf.append(": ");
044            buf.append(ae.getRequestHeader(name));
045            buf.append(CoreConstants.LINE_SEPARATOR);
046        }
047        buf.append(CoreConstants.LINE_SEPARATOR);
048        buf.append(ae.getRequestContent());
049        return buf.toString();
050    }
051
052}