// Path: src/main/java/com/github/mkopylec/errorest/handling/utils/HttpUtils.java
// public static String getHeadersAsText(HttpServletRequest request) {
//     Map<String, String> headers = new HashMap<>();
//     Enumeration<String> names = request.getHeaderNames();
//     while (names.hasMoreElements()) {
//         String name = names.nextElement();
//         if (!name.equals(AUTHORIZATION)) {
//             headers.put(name, request.getHeader(name));
//         }
//     }
//     return headers.toString();
// }


import org.springframework.core.Ordered;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import static com.github.mkopylec.errorest.handling.utils.HttpUtils.getHeadersAsText;
package com.github.mkopylec.errorest.handling;




public class RequestAttributeSettingFilter extends OncePerRequestFilter implements Ordered {

    public static final String REQUEST_HEADERS_ERROR_ATTRIBUTE = RequestAttributeSettingFilter.class.getName() + ".headers";

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        try {
            filterChain.doFilter(request, response);
        } catch (Throwable ex) {
// Path: src/main/java/com/github/mkopylec/errorest/handling/utils/HttpUtils.java
// public static String getHeadersAsText(HttpServletRequest request) {
//     Map<String, String> headers = new HashMap<>();
//     Enumeration<String> names = request.getHeaderNames();
//     while (names.hasMoreElements()) {
//         String name = names.nextElement();
//         if (!name.equals(AUTHORIZATION)) {
//             headers.put(name, request.getHeader(name));
//         }
//     }
//     return headers.toString();
// }


// Path: src/main/java/com/github/mkopylec/errorest/handling/RequestAttributeSettingFilter.java
import org.springframework.core.Ordered;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import static com.github.mkopylec.errorest.handling.utils.HttpUtils.getHeadersAsText;

package com.github.mkopylec.errorest.handling;




public class RequestAttributeSettingFilter extends OncePerRequestFilter implements Ordered {

    public static final String REQUEST_HEADERS_ERROR_ATTRIBUTE = RequestAttributeSettingFilter.class.getName() + ".headers";

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        try {
            filterChain.doFilter(request, response);
        } catch (Throwable ex) {
            request.setAttribute(REQUEST_HEADERS_ERROR_ATTRIBUTE, getHeadersAsText(request));