import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
-class HttpUtils {
- final static String HEADER_AUTHORIZATION = "Authorization";
- final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
-
- final static String DEFAULT_PROTECTED_HANDLERS = "/org/argeo/cms/internal/http/protectedHandlers.xml";
- final static String WEBDAV_CONFIG = "/org/argeo/cms/internal/http/webdav-config.xml";
+public class HttpUtils {
+ public final static String HEADER_AUTHORIZATION = "Authorization";
+ public final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
static boolean isBrowser(String userAgent) {
return userAgent.contains("webkit") || userAgent.contains("gecko") || userAgent.contains("firefox")
|| userAgent.contains("opera") || userAgent.contains("browser");
}
- static void logRequestHeaders(Log log, HttpServletRequest request) {
+ public static void logResponseHeaders(Log log, HttpServletResponse response) {
+ if (!log.isDebugEnabled())
+ return;
+ for (String headerName : response.getHeaderNames()) {
+ Object headerValue = response.getHeader(headerName);
+ log.debug(headerName + ": " + headerValue);
+ }
+ }
+
+ public static void logRequestHeaders(Log log, HttpServletRequest request) {
if (!log.isDebugEnabled())
return;
for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames.hasMoreElements();) {
log.debug(request.getRequestURI() + "\n");
}
- static void logRequest(Log log,HttpServletRequest request) {
+ public static void logRequest(Log log, HttpServletRequest request) {
log.debug("contextPath=" + request.getContextPath());
log.debug("servletPath=" + request.getServletPath());
log.debug("requestURI=" + request.getRequestURI());
log.debug("\n" + buf);
}
-
private HttpUtils() {
}