001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.http; 018 019/** 020 * Shared constants for the {@code X-Request-Id} correlation-id contract. 021 * 022 * <p> 023 * Homed in the security-neutral {@code org.apache.juneau.http} package ({@code juneau-rest-common}) so both the server 024 * ({@code juneau-rest-server}'s always-on session-build resolver and {@code RequestIdFilter}) and the client 025 * ({@code juneau-rest-client}'s auto-send interceptor and debug formatter) reference one source of truth without a 026 * package cycle. The header name is intentionally not duplicated as a bare literal in either module. 027 * 028 * <h5 class='section'>See Also:</h5><ul> 029 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestServerLoggingAndDebugging">Logging / Debugging</a> 030 * </ul> 031 * 032 * @since 10.0.0 033 */ 034@SuppressWarnings({ 035 "java:S115" // Constant mirrors an external protocol literal (the X-Request-Id HTTP header name). 036}) 037public final class RequestIdConstants { 038 039 /** The canonical request/response correlation-id header name: {@code "X-Request-Id"}. */ 040 public static final String HEADER = "X-Request-Id"; 041 042 /** 043 * The maximum sanitized character length of an honored correlation id. 044 * 045 * <p> 046 * Generous versus a 36-character UUID, roomy enough for common non-UUID trace-id shapes, and still firmly bounded. 047 * A client-supplied id whose {@link DebugTextSanitizer#sanitize(String, int) sanitized} form would exceed this cap 048 * is discarded in favor of a freshly minted id rather than echoed truncated. 049 */ 050 public static final int MAX_LEN = 128; 051 052 private RequestIdConstants() {} 053}