package org.maskat.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

public class DebugUtil {

	public static void printRequestContent(HttpServletRequest request)
			throws IOException {
		System.out.println("---------Request Content Start...");
		BufferedReader reader = new BufferedReader(request.getReader());
		String line = null;
		while ((line = reader.readLine()) != null) {
			System.out.println(line);
		}
		System.out.println("---------Request Content End.");
	}

	public static void printRequestHeaderInfo(HttpServletRequest request) {
		Enumeration reqHEnum = request.getHeaderNames();
		System.out.println("---------Http Header Information Start...");
		while (reqHEnum.hasMoreElements()) {
			String key = (String) reqHEnum.nextElement();
			System.out.println(key + ":" + request.getHeader(key));
		}
		System.out.println("---------Http Header Information End.");
	}
}
