package microservices.demo;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

@Component
public class RequestHeaderLoggingFilter extends ZuulFilter {
	private static Logger logger = LoggerFactory.getLogger(RequestHeaderLoggingFilter.class);

	@Override
	public String filterType() {
		return "pre";
	}

	@Override
	public int filterOrder() {
		return 99;
	}

	@Override
	public boolean shouldFilter() {
		return true;
	}

	@Override
	public Object run() {
		RequestContext ctx = RequestContext.getCurrentContext();
		Map<String, String> headers = ctx.getZuulRequestHeaders();

		logger.info("Request headers:");
		if (headers != null) {
			headers.forEach((key, value) -> {
				logger.info("Header[" + key + "]=[" + value + "]");
			});
		}

		return null;
	}

}

@@ -39,19 +39,74 @@
 va.util.
-Map
+Enumeration;%0A%0Aimport javax.servlet.http.HttpServletRequest
 ;%0A%0Aimpor
@@ -735,35 +735,34 @@
 ;%0A%09%09
-Map%3CString, String%3E headers
+HttpServletRequest request
  = c
@@ -771,30 +771,21 @@
 .get
-Zuul
 Request
-Headers
 ();%0A
+%09%09
 %0A%09%09l
@@ -822,20 +822,36 @@
 ;%0A%09%09
-if (
+Enumeration%3CString%3E 
 headers 
 != n
@@ -850,57 +850,113 @@
 ers 
-!
 = 
-null) %7B%0A%09%09%09headers.forEach((key, value) -%3E %7B%0A%09
+request.getHeaderNames();%0A%09%09while(headers.hasMoreElements()) %7B%0A%09%09%09String name = headers.nextElement();%0A
 %09%09%09l
@@ -982,11 +982,12 @@
 %22 + 
-key
+name
  + %22
@@ -997,33 +997,46 @@
 %22 + 
-value + %22%5D%22);%0A%09%09%09%7D
+request.getHeader(name) + %22%5D%22
 );%0A%09%09%7D%0A
+%09%09
 %0A%09%09r

Fix Zuul filter