All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.spt.development.cid.web.util.HttpHeaderUtils Maven / Gradle / Ivy

Go to download

A simple library for initialising the correlation ID associated with incoming web requests.

There is a newer version: 2.0.19
Show newest version
package com.spt.development.cid.web.util;

import java.util.regex.Pattern;

/**
 * Utility methods related to HTTP headers.
 */
public final class HttpHeaderUtils {
    private static final String EMPTY = "";

    private static final Pattern SANITIZE_PATTERN = Pattern.compile("[\\r\\n]");

    private HttpHeaderUtils() {}

    /**
     * Removes carriage return (\r) and newline (\n) characters from header (string) values.
     *
     * @param value the header value to sanitize.
     *
     * @return the sanitized value.
     */
    public static String sanitizeHeaderValue(String value) {
        return SANITIZE_PATTERN.matcher(value).replaceAll(EMPTY);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy