Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:APIJSON APIJSON Demo RepeatHeaderFilter

From Leeroopedia
Knowledge Sources
Domains Web_Framework, HTTP, Middleware
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete tool for deduplicating HTTP request headers by preferring x-header variants when both header and x-header are present.

Description

The RepeatHeaderFilter is a Spring OncePerRequestFilter that wraps the HttpServletRequest to resolve duplicate header issues. When a non-x- prefixed header is requested, it first checks for the x- prefixed equivalent and returns that value if present. This prevents parsing errors when APIJSON clients send both header and x-header simultaneously.

Usage

Register this filter (via @Component) when your APIJSON server receives requests with duplicate headers and needs to prefer the x- prefixed variant.

Code Reference

Source Location

Signature

@Component
public class RepeatHeaderFilter extends OncePerRequestFilter {
    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
            throws ServletException, IOException;
}

Import

import apijson.boot.RepeatHeaderFilter;

I/O Contract

Inputs

Name Type Required Description
request HttpServletRequest Yes Incoming HTTP request with possible duplicate headers
response HttpServletResponse Yes HTTP response
filterChain FilterChain Yes Servlet filter chain

Outputs

No direct output; wraps request and passes to next filter.

Usage Examples

Automatic Registration

// RepeatHeaderFilter is annotated with @Component, so Spring Boot
// auto-registers it. No manual configuration needed.

// When a request arrives with both "Token" and "x-token" headers,
// request.getHeader("Token") returns the "x-token" value.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment