From 7ea4e0081a875672b4766c00f49ffc205878c3e9 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Wed, 28 Oct 2026 23:46:23 +0200 Subject: [PATCH 01/14] Release `v1.3.1`. --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- apiphany-core/pom.xml | 2 +- apiphany-httpclient5/pom.xml | 2 +- apiphany-integration-tests/pom.xml | 2 +- apiphany-okhttp/pom.xml | 2 +- apiphany-spring/pom.xml | 2 +- apiphany-test/pom.xml | 2 +- integration/apiphany-httpclient5-tests/pom.xml | 2 +- integration/apiphany-json-jackson2-tests/pom.xml | 2 +- integration/apiphany-json-jackson3-tests/pom.xml | 2 +- integration/apiphany-json-no-dependency-tests/pom.xml | 2 +- integration/apiphany-okhttp-tests/pom.xml | 2 +- integration/apiphany-spring-no-client-tests/pom.xml | 2 +- integration/apiphany-spring-tests/pom.xml | 2 +- pom.xml | 2 +- 16 files changed, 20 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 420ed083..7b200a77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Release Notes +`1.3.1` + +--- + `1.3.0` - Added Jackson 3 support to `SpringJson` via `Jackson3SpringJson` for `JacksonJsonHttpMessageConverter`. diff --git a/README.md b/README.md index 20b47faa..f5e33fd5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Support is being developed for other HTTP clients like Netty, Jersey, etc. If yo ### Releases -Current release `1.3.0` +Current release `1.3.1` ### Getting Started @@ -62,7 +62,7 @@ Maven: add this dependency to your `pom.xml` io.github.raduking apiphany - 1.3.0 + 1.3.1 ``` diff --git a/apiphany-core/pom.xml b/apiphany-core/pom.xml index 10f3d7d6..19e4fd72 100644 --- a/apiphany-core/pom.xml +++ b/apiphany-core/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 apiphany diff --git a/apiphany-httpclient5/pom.xml b/apiphany-httpclient5/pom.xml index a0ac0eae..a3f7a50f 100644 --- a/apiphany-httpclient5/pom.xml +++ b/apiphany-httpclient5/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 apiphany-httpclient5 diff --git a/apiphany-integration-tests/pom.xml b/apiphany-integration-tests/pom.xml index ef69df6b..2ee2cb41 100644 --- a/apiphany-integration-tests/pom.xml +++ b/apiphany-integration-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 apiphany-integration-tests diff --git a/apiphany-okhttp/pom.xml b/apiphany-okhttp/pom.xml index 64a80fcc..194636cd 100644 --- a/apiphany-okhttp/pom.xml +++ b/apiphany-okhttp/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 apiphany-okhttp diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index 2badad0f..b3e5ed20 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -7,7 +7,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 apiphany-spring diff --git a/apiphany-test/pom.xml b/apiphany-test/pom.xml index a7ae4037..947c9527 100644 --- a/apiphany-test/pom.xml +++ b/apiphany-test/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 apiphany-test diff --git a/integration/apiphany-httpclient5-tests/pom.xml b/integration/apiphany-httpclient5-tests/pom.xml index d6c28d55..121c6eef 100644 --- a/integration/apiphany-httpclient5-tests/pom.xml +++ b/integration/apiphany-httpclient5-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/integration/apiphany-json-jackson2-tests/pom.xml b/integration/apiphany-json-jackson2-tests/pom.xml index 313606c8..a52e5a18 100644 --- a/integration/apiphany-json-jackson2-tests/pom.xml +++ b/integration/apiphany-json-jackson2-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/integration/apiphany-json-jackson3-tests/pom.xml b/integration/apiphany-json-jackson3-tests/pom.xml index d1709567..214d2a49 100644 --- a/integration/apiphany-json-jackson3-tests/pom.xml +++ b/integration/apiphany-json-jackson3-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/integration/apiphany-json-no-dependency-tests/pom.xml b/integration/apiphany-json-no-dependency-tests/pom.xml index 32410b28..70d05d00 100644 --- a/integration/apiphany-json-no-dependency-tests/pom.xml +++ b/integration/apiphany-json-no-dependency-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/integration/apiphany-okhttp-tests/pom.xml b/integration/apiphany-okhttp-tests/pom.xml index c6d1561a..5ac0a941 100644 --- a/integration/apiphany-okhttp-tests/pom.xml +++ b/integration/apiphany-okhttp-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/integration/apiphany-spring-no-client-tests/pom.xml b/integration/apiphany-spring-no-client-tests/pom.xml index 68d0d99d..e5ad668f 100644 --- a/integration/apiphany-spring-no-client-tests/pom.xml +++ b/integration/apiphany-spring-no-client-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/integration/apiphany-spring-tests/pom.xml b/integration/apiphany-spring-tests/pom.xml index 14dd7c47..53475750 100644 --- a/integration/apiphany-spring-tests/pom.xml +++ b/integration/apiphany-spring-tests/pom.xml @@ -8,7 +8,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 ../../pom.xml diff --git a/pom.xml b/pom.xml index c7ec5963..6db10283 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ io.github.raduking apiphany-parent - 1.3.0 + 1.3.1 pom ${project.groupId}:${project.artifactId} From e887ebf5dd52bcf364612fe1521e7528d927883d Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Thu, 29 Oct 2026 00:17:02 +0200 Subject: [PATCH 02/14] Install script with Maven only logs. --- install.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..b0cf891e --- /dev/null +++ b/install.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Exit immediately if the build fails. +set -e + +# Install all modules with Maven while redirecting test output to the test reports. +mvn clean install -Dmaven.test.redirectTestOutputToFile=true + From 5cabbeb809fcf4d22d3323cd2e6c31c7a15457e9 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Fri, 30 Oct 2026 23:32:34 +0200 Subject: [PATCH 03/14] Update dependencies with vulnerabilities. --- CHANGELOG.md | 6 ++ .../org/apiphany/header/HeaderValues.java | 21 +++++ .../java/org/apiphany/header/Headers.java | 48 ++++++++-- .../main/java/org/apiphany/lang/Strings.java | 87 ++++++++++--------- .../java/org/apiphany/header/HeadersTest.java | 42 +++++++++ apiphany-spring/pom.xml | 38 ++++++++ .../apiphany-spring-no-client-tests/pom.xml | 2 +- integration/apiphany-spring-tests/pom.xml | 2 +- pom.xml | 11 +-- 9 files changed, 200 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b200a77..c7711321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ `1.3.1` +- Preserved header insertion order in `Headers.of()`. +- Added `Headers.addTo()` overloads for opt-in header value normalization. +- Added `HeaderValues.normalize(String)` and `DANGEROUS_CHARACTERS` for dangerous-character normalization. +- Added `Strings.isEnvelopedBy(String, char)` and `isNotEnvelopedBy(String, char)`. +- Added `install.sh` to install all Maven modules with test output redirected to reports. + --- `1.3.0` diff --git a/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java b/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java index 5dc807d1..7f118052 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java +++ b/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java @@ -23,6 +23,11 @@ public class HeaderValues { */ public static final String REDACTED = Sensitive.Value.REDACTED; + /** + * An immutable list of dangerous characters that will be replaced whenever we add a header. + */ + public static final List DANGEROUS_CHARACTERS = List.of('\0', '\r', '\n'); + /** * The next {@link HeaderValues} in the chain of responsibility. If {@code null}, this represents the end of the chain. */ @@ -124,4 +129,20 @@ public static String value(final L lvalue, final R rvalue) { public static String value(final L lvalue, final R rvalue, final String separator) { return String.join(separator, Strings.safeToString(lvalue), Strings.safeToString(rvalue)); } + + /** + * Normalizes dangerous characters in a header field value before it is added to a headers map. + *

+ * Replace {@code CR}, {@code LF}, and {@code NUL} characters before processing or forwarding a header value. + * + * @param value the header field value + * @return the normalized header field value + */ + public static String normalize(final String value) { + String normalizedValue = value; + for (char dangerousCharacter : DANGEROUS_CHARACTERS) { + normalizedValue = normalizedValue.replace(dangerousCharacter, ' '); + } + return normalizedValue; + } } diff --git a/apiphany-core/src/main/java/org/apiphany/header/Headers.java b/apiphany-core/src/main/java/org/apiphany/header/Headers.java index 6c6a2b07..33dff600 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/Headers.java +++ b/apiphany-core/src/main/java/org/apiphany/header/Headers.java @@ -3,11 +3,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.BiPredicate; import java.util.function.Function; +import java.util.function.UnaryOperator; import org.apiphany.lang.Strings; import org.morphix.lang.collections.Lists; @@ -37,7 +38,7 @@ static Map> of(final HeaderFunction... headerFunctions) { if (null == headerFunctions || 0 == headerFunctions.length) { return Collections.emptyMap(); } - var map = new HashMap>(); + var map = new LinkedHashMap>(); for (HeaderFunction headerFunction : headerFunctions) { headerFunction.addTo(map); } @@ -54,10 +55,24 @@ static Map> of(final HeaderFunction... headerFunctions) { * @param headers headers map */ static void addTo(final Map> existingHeaders, final Map headers) { + addTo(existingHeaders, headers, UnaryOperator.identity()); + } + + /** + * Adds headers to existing headers using the given value normalizer. + * + * @param header name type + * @param header value type + * + * @param existingHeaders existing headers + * @param headers headers map + * @param valueNormalizer function applied to each non-empty header value + */ + static void addTo(final Map> existingHeaders, final Map headers, final UnaryOperator valueNormalizer) { for (Map.Entry header : Maps.safe(headers).entrySet()) { N headerName = header.getKey(); H headerValue = header.getValue(); - addTo(existingHeaders, headerName, headerValue); + addTo(existingHeaders, headerName, headerValue, valueNormalizer); } } @@ -73,6 +88,22 @@ static void addTo(final Map> existingHeaders, final * @param headerValue header value */ static void addTo(final Map> existingHeaders, final N headerName, final H headerValue) { + addTo(existingHeaders, headerName, headerValue, UnaryOperator.identity()); + } + + /** + * Adds a header to existing headers using the given value normalizer. + * + * @param header name type + * @param header value type + * + * @param existingHeaders existing headers + * @param headerName header name + * @param headerValue header value + * @param valueNormalizer function applied to each non-empty header value + */ + static void addTo(final Map> existingHeaders, final N headerName, final H headerValue, + final UnaryOperator valueNormalizer) { if (null == headerName) { return; } @@ -87,7 +118,10 @@ static void addTo(final Map> existingHeaders, final headerValues.forEach(hv -> { String stringValue = Strings.safeToString(hv); if (Strings.isNotEmpty(stringValue)) { - existing.add(stringValue); + String normalizedValue = valueNormalizer.apply(stringValue); + if (Strings.isNotEmpty(normalizedValue)) { + existing.add(normalizedValue); + } } }); } @@ -197,15 +231,15 @@ static boolean contains(final N headerName, final Map> * * @param header name type * - * @param header the name of the header whose values are to be retrieved. + * @param headerName the name of the header whose values are to be retrieved. * @param headers the map of headers, where each key is a header name and the value is a list of header values. * @return a list of values for the specified header. If the header is not found, an empty list is returned. */ - static List get(final N header, final Map> headers) { + static List get(final N headerName, final Map> headers) { if (Maps.isEmpty(headers)) { return Collections.emptyList(); } - String headerKey = Strings.safeToString(header); + String headerKey = Strings.safeToString(headerName); List values = headers.get(headerKey); if (null != values) { return values; diff --git a/apiphany-core/src/main/java/org/apiphany/lang/Strings.java b/apiphany-core/src/main/java/org/apiphany/lang/Strings.java index 20751eff..d7a48fdd 100644 --- a/apiphany-core/src/main/java/org/apiphany/lang/Strings.java +++ b/apiphany-core/src/main/java/org/apiphany/lang/Strings.java @@ -18,18 +18,18 @@ * {@link String} utility methods. *

* This class prefers to return {@code null} instead of throwing exceptions when an error occurs, so it is the caller's - * responsibility to handle the errors by checking for null values and using the provided onError handlers. + * responsibility to handle the errors by checking for {@code null} values and using the provided onError handlers. *

* This design choice is made to provide a more functional programming style and to allow the caller to decide how to * handle errors, whether by logging, throwing custom exceptions, or using default values and to avoid the need for * try-catch blocks in the calling code, thus promoting cleaner and more readable code. The other major reason is * performance, as throwing exceptions can be costly in terms of performance, especially in cases where errors are - * expected to occur frequently. By returning null, we can avoid the overhead associated with exception handling and - * allow the caller to handle errors in a more efficient way. + * expected to occur frequently. By returning {@code null}, we can avoid the overhead associated with exception handling + * and allow the caller to handle errors in a more efficient way. *

- * However, it is important to note that this approach may lead to null pointer exceptions if the caller does not - * properly handle the null values, so it is crucial to always check for null returns when using these methods and to - * use the onError handlers to manage exceptions appropriately. + * However, it is important to note that this approach may lead to {@link NullPointerException}s if the caller does not + * properly handle the {@code null} values, so it is crucial to always check for {@code null} returns when using these + * methods and to use the onError handlers to manage exceptions appropriately. * * @author Radu Sebastian LAZIN */ @@ -46,7 +46,8 @@ public interface Strings { Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; /** - * Returns the call of {@link Object#toString()} on the given parameter if the parameter is not null, null otherwise. + * Returns the call of {@link Object#toString()} on the given parameter if the parameter is not {@code null}, + * {@code null} otherwise. * * @param o object * @return the string representation of the object @@ -56,40 +57,40 @@ static String safeToString(final Object o) { } /** - * Returns the parameter if it is not null, empty string otherwise. + * Returns the parameter if it is not {@code null}, empty string otherwise. * * @param s a string - * @return the parameter if it is not null, empty string otherwise + * @return the parameter if it is not {@code null}, empty string otherwise */ static String safe(final String s) { return null != s ? s : ""; } /** - * Checks if a CharSequence is empty ("") or null. + * Checks if a {@link CharSequence} is empty ("") or {@code null}. * - * @param cs the CharSequence to check, may be null - * @return {@code true} if the CharSequence is empty or null + * @param cs the {@link CharSequence} to check, may be {@code null} + * @return {@code true} if the {@link CharSequence} is empty or {@code null} */ static boolean isEmpty(final CharSequence cs) { return null == cs || cs.isEmpty(); } /** - * Checks if a CharSequence is not empty ("") or null. + * Checks if a {@link CharSequence} is not empty ("") or {@code null}. * - * @param cs the CharSequence to check, may be null - * @return {@code true} if the CharSequence is not empty or null + * @param cs the {@link CharSequence} to check, may be {@code null} + * @return {@code true} if the {@link CharSequence} is not empty or {@code null} */ static boolean isNotEmpty(final CharSequence cs) { return !isEmpty(cs); } /** - * Checks if a CharSequence is whitespace, empty ("") or null. + * Checks if a {@link CharSequence} is whitespace, empty ("") or {@code null}. * - * @param cs the CharSequence to check, may be null - * @return {@code true} if the CharSequence is whitespace, empty or null + * @param cs the {@link CharSequence} to check, may be {@code null} + * @return {@code true} if the {@link CharSequence} is whitespace, empty or {@code null} */ static boolean isBlank(final CharSequence cs) { if (isEmpty(cs)) { @@ -105,10 +106,10 @@ static boolean isBlank(final CharSequence cs) { } /** - * Checks if a CharSequence is not whitespace, empty ("") or null. + * Checks if a {@link CharSequence} is not whitespace, empty ("") or {@code null}. * - * @param cs the CharSequence to check, may be null - * @return {@code true} if the CharSequence is not whitespace, empty or null + * @param cs the {@link CharSequence} to check, may be {@code null} + * @return {@code true} if the {@link CharSequence} is not whitespace, empty or {@code null} */ static boolean isNotBlank(final CharSequence cs) { return !isBlank(cs); @@ -116,7 +117,7 @@ static boolean isNotBlank(final CharSequence cs) { /** * Transforms a string from Lower Camel case to Snake case. The Lower Camel case is the Java convention for naming - * methods. Example: "someCoolName" will be "some_cool_name". + * methods. Example: {@code "someCoolName"} will be {@code "some_cool_name"}. * * @param str string to transform * @return snake case string @@ -137,7 +138,7 @@ static String fromCamelToSnakeCase(final String str) { /** * Transforms a string from Lower Camel case to Kebab case. The Lower Camel case is the Java convention for naming - * methods. Example: "someCoolName" will be "some-cool-name". + * methods. Example: {@code "someCoolName"} will be {@code "some-cool-name"}. * * @param str string to transform * @return kebab case string @@ -157,8 +158,8 @@ static String fromCamelToKebabCase(final String str) { } /** - * Transforms a string from Kebab case to Lower Camel case. Example: "some-cool-name" will become - * "someCoolName". + * Transforms a string from Kebab case to Lower Camel case. Example: {@code "some-cool-name"} will become + * {@code "someCoolName"}. * * @param str string to transform * @return lower camel case string @@ -185,7 +186,7 @@ static String fromKebabToCamelCase(final String str) { * @param encoding character encoding to use when reading the input stream * @param maxSize maximum size in characters to read from the input stream * @param bufferSize buffer size in characters to use when reading the input stream - * @param onError on error handler, must not be null + * @param onError on error handler, must not be {@code null} * @return the input stream as string */ static String toString(final InputStream inputStream, final Charset encoding, final int maxSize, final int bufferSize, @@ -217,7 +218,7 @@ static String toString(final InputStream inputStream, final Charset encoding, fi /** * Transforms an input stream to a string. If the input stream cannot be converted to string with the given parameters, - * the result will be null. This method is not intended for large streams and is also limited to read up to + * the result will be {@code null}. This method is not intended for large streams and is also limited to read up to * {@link IOStreams#MAX_BUFFER_SIZE} characters from the input stream. * * @param inputStream input stream @@ -231,7 +232,7 @@ static String toString(final InputStream inputStream, final Charset encoding, fi /** * Transforms an input stream to a string. If the input stream cannot be converted to string with the given parameters, - * the result will be null. This method is not intended for large streams and is also limited to read up to + * the result will be {@code null}. This method is not intended for large streams and is also limited to read up to * {@link IOStreams#MAX_BUFFER_SIZE} characters from the input stream. * * @param inputStream input stream @@ -244,8 +245,8 @@ static String toString(final InputStream inputStream, final Charset encoding) { /** * Transforms a byte array to a string. If the byte array cannot be converted to string with the given parameters, the - * result will be null. This method is not intended for large byte arrays and is also limited to read up to the given - * maximum size bytes from the byte array. + * result will be {@code null}. This method is not intended for large byte arrays and is also limited to read up to the + * given maximum size bytes from the byte array. * * @param bytes byte array to convert * @param encoding character encoding @@ -263,7 +264,7 @@ static String toString(final byte[] bytes, final Charset encoding, final int max /** * Transforms a byte array to a string. If the byte array cannot be converted to string with the given parameters, the - * result will be null. This method is not intended for large byte arrays and is also limited to read up to + * result will be {@code null}. This method is not intended for large byte arrays and is also limited to read up to * {@link IOStreams#MAX_BUFFER_SIZE} bytes from the byte array. * * @param bytes byte array to convert @@ -277,7 +278,7 @@ static String toString(final byte[] bytes, final Charset encoding, final Consume /** * Transforms a byte array to a string. If the byte array cannot be converted to string with the given parameters, the - * result will be null. This method is not intended for large byte arrays and is also limited to read up to + * result will be {@code null}. This method is not intended for large byte arrays and is also limited to read up to * {@link IOStreams#MAX_BUFFER_SIZE} bytes from the byte array. * * @param bytes byte array to convert @@ -290,7 +291,7 @@ static String toString(final byte[] bytes, final Charset encoding) { /** * Transforms a byte array to a string. If the byte array cannot be converted to string with the given parameters, the - * result will be null. This method is not intended for large byte arrays and is also limited to read up to + * result will be {@code null}. This method is not intended for large byte arrays and is also limited to read up to * {@link IOStreams#MAX_BUFFER_SIZE} characters from the byte array. It assumes that the encoding is * {@link #DEFAULT_CHARSET}. Use this method only if the byte array to be read respects this condition. * @@ -303,7 +304,7 @@ static String toString(final byte[] bytes) { /** * Transforms a byte array to a string. If the byte array cannot be converted to string with the given parameters, the - * result will be null. This method is not intended for large byte arrays and is also limited to read up to + * result will be {@code null}. This method is not intended for large byte arrays and is also limited to read up to * {@link IOStreams#MAX_BUFFER_SIZE} characters from the byte array. It assumes that the encoding is * {@link #DEFAULT_CHARSET}. Use this method only if the byte array to be read respects this condition. * @@ -321,7 +322,7 @@ static String toString(final byte[] bytes, final int maxSize) { * If the given path is an absolute path, it is considered a file system path otherwise, it is considered a classpath * resource. * - * @param path path to the file, must not be null + * @param path path to the file, must not be {@code null} * @param encoding the file encoding * @param bufferSize the size in characters of the buffer while reading the file * @param onError on error handler @@ -418,8 +419,8 @@ static String removeAllWhitespace(final String input) { } /** - * Strips the given character from the start and end of the input string. If the string is null, returns null. If empty, - * returns empty. + * Strips the given character from the start and end of the input string. If the string is {@code null}, returns + * {@code null}. If empty, returns empty. * * @param input the input string to strip * @param ch the character to strip @@ -507,18 +508,18 @@ static String preview(final byte[] value, final int maxLength) { } /** - * Checks if the given string ends with any of the given characters. Returns {@code false} if the string is null or - * empty. + * Checks if the given string ends with any of the given characters. Returns {@code false} if the string is {@code null} + * or empty. * - * @param str the string to check, may be null + * @param input the string to check, may be {@code null} * @param chars the characters to check against * @return {@code true} if the string ends with any of the given characters */ - static boolean endsWithAny(final String str, final char... chars) { - if (isEmpty(str)) { + static boolean endsWithAny(final String input, final char... chars) { + if (isEmpty(input)) { return false; } - char last = str.charAt(str.length() - 1); + char last = input.charAt(input.length() - 1); for (char c : chars) { if (last == c) { return true; diff --git a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java index a980efd3..69249c91 100644 --- a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java +++ b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java @@ -184,6 +184,38 @@ void shouldNotAddEmptyHeaderValueToExistingHeader() { assertThat(headers, equalTo(expected)); } + @Test + void shouldPreserveQuotedHeaderValue() { + Headers.addTo(headers, N2, "\"a,b with spaces\""); + + assertThat(headers.get(N2), equalTo(List.of("\"a,b with spaces\""))); + } + + @Test + void shouldPreserveDangerousHeaderValueByDefault() { + Headers.addTo(headers, N2, "safe\r\ninvalid"); + Headers.addTo(headers, N2, List.of("invalid\n")); + Headers.addTo(headers, N2, new String[] { "invalid\0" }); + + assertThat(headers.get(N2), equalTo(List.of("safe\r\ninvalid", "invalid\n", "invalid\0"))); + } + + @Test + void shouldNormalizeDangerousHeaderValueWhenExplicitlyRequested() { + Headers.addTo(headers, N2, "safe\r\ninvalid", HeaderValues::normalize); + Headers.addTo(headers, N2, List.of("invalid\n"), HeaderValues::normalize); + Headers.addTo(headers, N2, new String[] { "invalid\0" }, HeaderValues::normalize); + + assertThat(headers.get(N2), equalTo(List.of("safe invalid", "invalid ", "invalid "))); + } + + @Test + void shouldNormalizeMapHeaderValuesWhenExplicitlyRequested() { + Headers.addTo(headers, Map.of(N2, "safe\r\ninvalid"), HeaderValues::normalize); + + assertThat(headers.get(N2), equalTo(List.of("safe invalid"))); + } + @ParameterizedTest @MethodSource("provideNullAndEmptyValues") void shouldNotAddNullHeaderValueToExistingHeaderButAddHeader(final String v1, final String v2) { @@ -378,6 +410,16 @@ void shouldCreateHeadersMapWithAllHeaders() { assertThat(resultHeaders, equalTo(expected)); } + @Test + void shouldPreserveHeaderInsertionOrder() { + Map> resultHeaders = Headers.of( + HeaderFunction.header("first", "1"), + HeaderFunction.header("second", "2"), + HeaderFunction.header("third", "3")); + + assertThat(List.copyOf(resultHeaders.keySet()), equalTo(List.of("first", "second", "third"))); + } + @Test void shouldCreateHeadersMapWithNoHeaders() { Map> resultHeaders = Headers.of(); diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index b3e5ed20..e560dea9 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -123,30 +123,60 @@ + + com.fasterxml.jackson.core + jackson-databind + ${jackson2.version} + provided + true + + com.fasterxml.jackson.datatype jackson-datatype-jsr310 + ${jackson2.version} provided true + + + com.fasterxml.jackson.core + jackson-databind + + com.fasterxml.jackson.datatype jackson-datatype-jdk8 + ${jackson2.version} provided true + + + com.fasterxml.jackson.core + jackson-databind + + com.fasterxml.jackson.dataformat jackson-dataformat-xml + ${jackson2.version} provided true + + + com.fasterxml.jackson.core + jackson-databind + + tools.jackson.core jackson-databind + ${jackson3.version} provided true @@ -154,14 +184,22 @@ tools.jackson.dataformat jackson-dataformat-xml + ${jackson3.version} provided true + + + tools.jackson.core + jackson-databind + + ch.qos.logback logback-classic + ${logback.version} test diff --git a/integration/apiphany-spring-no-client-tests/pom.xml b/integration/apiphany-spring-no-client-tests/pom.xml index e5ad668f..173b090e 100644 --- a/integration/apiphany-spring-no-client-tests/pom.xml +++ b/integration/apiphany-spring-no-client-tests/pom.xml @@ -112,7 +112,7 @@ com.jayway.jsonpath json-path - 3.0.0 + ${json.path.version} test diff --git a/integration/apiphany-spring-tests/pom.xml b/integration/apiphany-spring-tests/pom.xml index 53475750..d4140ad4 100644 --- a/integration/apiphany-spring-tests/pom.xml +++ b/integration/apiphany-spring-tests/pom.xml @@ -157,7 +157,7 @@ com.jayway.jsonpath json-path - 3.0.0 + ${json.path.version} test diff --git a/pom.xml b/pom.xml index 6db10283..d97831fc 100644 --- a/pom.xml +++ b/pom.xml @@ -64,8 +64,8 @@ 1.0.47 1.17.2 - 2.21.7 - 3.1.7 + 2.21.8 + 3.1.8 2.0.20 5.6.5 4.12.1 @@ -85,18 +85,19 @@ 3.0 6.1.3 5.24.0 - 1.5.38 + 1.6.6 7.1.2 2.0.5 4.4.0 10.10 11.38.2 3.13.2 + 3.0.0 - 3.45.0 + 3.47.0 4.38 - 1.0.0 + 1.1.0 3.2.8 From 640dcd7c1a8beaa7137c321ca00a9a6b8e9c51dd Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Sun, 1 Nov 2026 17:27:47 +0200 Subject: [PATCH 04/14] Document changes. --- CHANGELOG.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7711321..3c15b00f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,16 @@ - Preserved header insertion order in `Headers.of()`. - Added `Headers.addTo()` overloads for opt-in header value normalization. -- Added `HeaderValues.normalize(String)` and `DANGEROUS_CHARACTERS` for dangerous-character normalization. -- Added `Strings.isEnvelopedBy(String, char)` and `isNotEnvelopedBy(String, char)`. +- Added `HeaderValues.normalize(String)` and `HeaderValues.DANGEROUS_CHARACTERS` for dangerous-character normalization. +- Added `Strings.isEnvelopedBy(String, char)` to check if a string starts and ends with the given character. +- Added `Strings.isNotEnvelopedBy(String, char)` to check if a string does not start and end with the given character. - Added `install.sh` to install all Maven modules with test output redirected to reports. +- Upgraded Jackson 2 to `2.21.8`. +- Upgraded Jackson 3 to `3.1.8`. +- Upgraded `logback-core` to `1.6.6`. +- Upgraded `org.eclipse.jdt.core` to `3.47.0`. +- Upgraded `code-format` to `1.1.0`. +- Pinned Jackson 2 and 3 optional dependencies in `apiphany-spring` to `${jackson2.version}` and `${jackson3.version}`. --- From a4ea1852295c8776027366b4601a75176d6522ca Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Sun, 1 Nov 2026 18:39:07 +0200 Subject: [PATCH 05/14] Simplify header values chain methods. --- .../org/apiphany/header/HeaderValues.java | 4 ++-- .../org/apiphany/header/MapHeaderValues.java | 3 +++ .../org/apiphany/http/HttpHeaderValues.java | 5 ++--- .../apiphany/header/MapHeaderValuesTest.java | 20 +++++++++++++++++++ .../apiphany/http/HttpHeaderValuesTest.java | 20 +++++++++++++++++++ 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java b/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java index 7f118052..161a8b18 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java +++ b/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java @@ -8,8 +8,8 @@ import org.apiphany.security.Sensitive; /** - * Represents a node in a chain of responsibility for resolving HTTP header values. Each instance can either handle a - * header request directly or delegate it to the next {@link HeaderValues} in the chain. + * Represents a node in a chain of responsibility for resolving header values. Each instance can either handle a header + * request directly or delegate it to the next {@link HeaderValues} in the chain. *

* By default, this implementation returns an empty list for all header requests, serving as a base class that can be * extended for custom behavior. diff --git a/apiphany-core/src/main/java/org/apiphany/header/MapHeaderValues.java b/apiphany-core/src/main/java/org/apiphany/header/MapHeaderValues.java index 97b7fe72..bfa4441f 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/MapHeaderValues.java +++ b/apiphany-core/src/main/java/org/apiphany/header/MapHeaderValues.java @@ -1,5 +1,6 @@ package org.apiphany.header; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -42,6 +43,7 @@ public MapHeaderValues() { @Override public List get(final N header, final Object headers) { return switch (headers) { + case null -> Collections.emptyList(); case Map map -> Headers.get(header, JavaObjects.cast(map)); default -> getNext().get(header, headers); }; @@ -68,6 +70,7 @@ public List get(final N header, final Object headers) { @Override public boolean contains(final N headerName, final V headerValue, final Object headers) { return switch (headers) { + case null -> false; case Map map -> Headers.contains(headerName, headerValue, JavaObjects.>>cast(map)); default -> getNext().contains(headerName, headerValue, headers); }; diff --git a/apiphany-core/src/main/java/org/apiphany/http/HttpHeaderValues.java b/apiphany-core/src/main/java/org/apiphany/http/HttpHeaderValues.java index 342dccd5..202da819 100644 --- a/apiphany-core/src/main/java/org/apiphany/http/HttpHeaderValues.java +++ b/apiphany-core/src/main/java/org/apiphany/http/HttpHeaderValues.java @@ -48,10 +48,8 @@ public HttpHeaderValues() { */ @Override public List get(final N header, final Object headers) { - if (null == headers) { - return Collections.emptyList(); - } return switch (headers) { + case null -> Collections.emptyList(); case HttpHeaders httpHeaders -> get(header, httpHeaders); default -> getNext().get(header, headers); }; @@ -73,6 +71,7 @@ public List get(final N header, final Object headers) { @Override public boolean contains(final N headerName, final V headerValue, final Object headers) { return switch (headers) { + case null -> false; case HttpHeaders httpHeaders -> Headers.contains(headerName, headerValue, httpHeaders.map()); default -> getNext().contains(headerName, headerValue, headers); }; diff --git a/apiphany-core/src/test/java/org/apiphany/header/MapHeaderValuesTest.java b/apiphany-core/src/test/java/org/apiphany/header/MapHeaderValuesTest.java index ef72dfbd..cfaa959b 100644 --- a/apiphany-core/src/test/java/org/apiphany/header/MapHeaderValuesTest.java +++ b/apiphany-core/src/test/java/org/apiphany/header/MapHeaderValuesTest.java @@ -44,6 +44,17 @@ void shouldReturnEmptyListOnGetFromEmptyHeadersMap() { assertThat(headerValues, hasSize(0)); } + @Test + void shouldReturnEmptyListOnGetFromNullHeaders() { + MapHeaderValues mhv = new MapHeaderValues(); + Object headers = null; + + List headerValues = mhv.get("Some-Header", headers); + + assertThat(headerValues, notNullValue()); + assertThat(headerValues, hasSize(0)); + } + @Test void shouldThrowExceptionOnNextForSimpleInstance() { MapHeaderValues mhv = new MapHeaderValues(); @@ -138,6 +149,15 @@ void shouldReturnFalseOnContainsFromEmptyMapHeadersWithMapHeaderValuesObject() { assertThat(result, equalTo(false)); } + @Test + void shouldReturnFalseOnContainsFromNullHeaders() { + MapHeaderValues mhv = new MapHeaderValues(); + + boolean result = mhv.contains(HEADER_NAME, HEADER_VALUE, null); + + assertThat(result, equalTo(false)); + } + @Test void shouldReturnFalseWhenCheckingExistingHeaderInEmptyHeadersOnContains() { boolean result = MapHeaderValues.contains(HEADER_NAME, Collections.emptyMap()); diff --git a/apiphany-core/src/test/java/org/apiphany/http/HttpHeaderValuesTest.java b/apiphany-core/src/test/java/org/apiphany/http/HttpHeaderValuesTest.java index e73993e2..b16d4554 100644 --- a/apiphany-core/src/test/java/org/apiphany/http/HttpHeaderValuesTest.java +++ b/apiphany-core/src/test/java/org/apiphany/http/HttpHeaderValuesTest.java @@ -47,6 +47,17 @@ void shouldReturnEmptyListOnGetFromEmptyHeadersMap() { assertThat(headerValues, hasSize(0)); } + @Test + void shouldReturnEmptyListOnGetFromNullHeaders() { + HttpHeaderValues hhv = new HttpHeaderValues(); + Object headers = null; + + List headerValues = hhv.get("Some-Header", headers); + + assertThat(headerValues, notNullValue()); + assertThat(headerValues, hasSize(0)); + } + @Test void shouldThrowExceptionOnNextForSimpleInstance() { HttpHeaderValues hhv = new HttpHeaderValues(); @@ -142,6 +153,15 @@ void shouldReturnFalseOnContainsFromEmptyMapHeadersWithMapHeaderValuesObject() { assertThat(result, equalTo(false)); } + @Test + void shouldReturnFalseOnContainsFromNullHeaders() { + HttpHeaderValues hhv = new HttpHeaderValues(); + + boolean result = hhv.contains(HEADER_NAME, HEADER_VALUE, null); + + assertThat(result, equalTo(false)); + } + @Test void shouldReturnFalseWhenCheckingExistingHeaderInEmptyHeadersOnContains() { HttpHeaders httpHeaders = HttpHeaders.of(Map.of(), (name, value) -> true); From fe3384eba107bc8cdcf4aa0d10103804d2edfa8f Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 2 Nov 2026 01:06:52 +0200 Subject: [PATCH 06/14] Fixed redacted header values to be a singleton list. --- .../java/org/apiphany/client/ExchangeClient.java | 5 ++--- .../main/java/org/apiphany/header/HeaderValues.java | 7 +++++-- .../org/apiphany/client/ExchangeClientTest.java | 3 +-- .../client/http/HttpExchangeClientTest.java | 6 ------ .../java/org/apiphany/header/HeaderValuesTest.java | 13 +++++++++++++ 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/apiphany-core/src/main/java/org/apiphany/client/ExchangeClient.java b/apiphany-core/src/main/java/org/apiphany/client/ExchangeClient.java index f8c17e39..4f6ec3de 100644 --- a/apiphany-core/src/main/java/org/apiphany/client/ExchangeClient.java +++ b/apiphany-core/src/main/java/org/apiphany/client/ExchangeClient.java @@ -13,7 +13,6 @@ import org.apiphany.header.HeaderValues; import org.apiphany.logging.DiagnosticContext; import org.apiphany.security.AuthenticationType; -import org.apiphany.security.Sensitive; import org.morphix.lang.collections.Maps; import org.morphix.lang.function.Predicates; import org.morphix.lang.thread.Threads; @@ -155,7 +154,7 @@ default Map> getDisplayHeaders(final ApiMessage apiM return Collections.emptyMap(); } Map> headers = apiMessage.getHeaders(); - return Maps.replace(headers, isSensitiveHeader(), () -> Collections.singletonList(HeaderValues.REDACTED)); + return Maps.replace(headers, isSensitiveHeader(), () -> HeaderValues.REDACTED); } /** @@ -173,7 +172,7 @@ default Map> getDisplayParams(final ApiRequest apiRe return Collections.emptyMap(); } Map> params = apiRequest.getParams(); - return Maps.replace(params, isSensitiveParam(), () -> Collections.singletonList(Sensitive.Value.REDACTED)); + return Maps.replace(params, isSensitiveParam(), () -> HeaderValues.REDACTED); } /** diff --git a/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java b/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java index 161a8b18..be129307 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java +++ b/apiphany-core/src/main/java/org/apiphany/header/HeaderValues.java @@ -12,7 +12,10 @@ * request directly or delegate it to the next {@link HeaderValues} in the chain. *

* By default, this implementation returns an empty list for all header requests, serving as a base class that can be - * extended for custom behavior. + * extended for custom behavior but also allowing for delegation to subsequent handlers in the chain. + *

+ * This class is also intended to be used as the last element in the chain, where it can provide default behavior + * (returning an empty list) when no other handler can resolve the header. * * @author Radu Sebastian LAZIN */ @@ -21,7 +24,7 @@ public class HeaderValues { /** * The string used to redact sensitive information. */ - public static final String REDACTED = Sensitive.Value.REDACTED; + public static final List REDACTED = Collections.singletonList(Sensitive.Value.REDACTED); /** * An immutable list of dangerous characters that will be replaced whenever we add a header. diff --git a/apiphany-core/src/test/java/org/apiphany/client/ExchangeClientTest.java b/apiphany-core/src/test/java/org/apiphany/client/ExchangeClientTest.java index 57e86299..a0afe2da 100644 --- a/apiphany-core/src/test/java/org/apiphany/client/ExchangeClientTest.java +++ b/apiphany-core/src/test/java/org/apiphany/client/ExchangeClientTest.java @@ -19,7 +19,6 @@ import org.apiphany.Parameter; import org.apiphany.RequestParameters; import org.apiphany.header.Header; -import org.apiphany.header.HeaderValues; import org.apiphany.header.Headers; import org.apiphany.security.AuthenticationType; import org.apiphany.security.Sensitive; @@ -152,7 +151,7 @@ void shouldRedactSensitiveDisplayHeadersUsingIsSensitiveParamPredicate() { assertThat(headersForDisplay, equalTo(Map.of( "Content-Type", List.of("application/json"), - "My-Authorization", List.of(HeaderValues.REDACTED)))); + "My-Authorization", List.of(Sensitive.Value.REDACTED)))); } @Test diff --git a/apiphany-core/src/test/java/org/apiphany/client/http/HttpExchangeClientTest.java b/apiphany-core/src/test/java/org/apiphany/client/http/HttpExchangeClientTest.java index 45614983..3dc4ce0a 100644 --- a/apiphany-core/src/test/java/org/apiphany/client/http/HttpExchangeClientTest.java +++ b/apiphany-core/src/test/java/org/apiphany/client/http/HttpExchangeClientTest.java @@ -15,7 +15,6 @@ import org.apiphany.RequestMethod; import org.apiphany.client.ClientProperties; import org.apiphany.header.Header; -import org.apiphany.header.HeaderValues; import org.apiphany.header.Headers; import org.apiphany.http.HttpHeader; import org.apiphany.http.HttpMethod; @@ -215,11 +214,6 @@ void shouldReturnDisplayHeadersWithRedactedSensitiveValuesFromApiMessageWithHead "Cookie", List.of(Sensitive.Value.REDACTED)))); } - @Test - void shouldHaveTheSameRedactedValueAsSensitiveValueRedacted() { - assertThat(HeaderValues.REDACTED, equalTo(Sensitive.Value.REDACTED)); - } - @Test void shouldReturnConfiguredSensitiveHeaderAsSensitive() throws Exception { ClientProperties.Logging properties = new ClientProperties.Logging(); diff --git a/apiphany-core/src/test/java/org/apiphany/header/HeaderValuesTest.java b/apiphany-core/src/test/java/org/apiphany/header/HeaderValuesTest.java index da4afa05..3242db25 100644 --- a/apiphany-core/src/test/java/org/apiphany/header/HeaderValuesTest.java +++ b/apiphany-core/src/test/java/org/apiphany/header/HeaderValuesTest.java @@ -11,6 +11,7 @@ import java.util.stream.Stream; import org.apiphany.http.HttpHeaderValues; +import org.apiphany.security.Sensitive; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -27,6 +28,18 @@ class HeaderValuesTest { private static final String HEADER_VALUE2 = "headerValue2"; private static final String HEADER_NAME1 = "headerName1"; + @Test + void shouldHaveTheRedactedListDefinedAsTheRedactedValueFromSensitive() { + assertThat(HeaderValues.REDACTED, equalTo(Collections.singletonList(Sensitive.Value.REDACTED))); + } + + @Test + void shouldHaveTheDangerousCharactersListDefinedAsFollows() { + List expectedDangerousCharacters = List.of('\0', '\r', '\n'); + + assertThat(HeaderValues.DANGEROUS_CHARACTERS, equalTo(expectedDangerousCharacters)); + } + private static Stream provideHeadersObjectsForChainWithoutHandlers() { return Stream.of( Arguments.of(Map.of(HEADER_NAME1, List.of(HEADER_VALUE1))), From 0c3843f785f0e18f17af43d5265be041f29bfc21 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 2 Nov 2026 02:11:28 +0200 Subject: [PATCH 07/14] Formatting and JavaDoc. --- .../apiphany/client/http/AbstractHttpExchangeClient.java | 8 ++++---- .../apiphany/client/http/ApacheHC5HttpExchangeClient.java | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apiphany-core/src/main/java/org/apiphany/client/http/AbstractHttpExchangeClient.java b/apiphany-core/src/main/java/org/apiphany/client/http/AbstractHttpExchangeClient.java index 76fce3d8..40ddf821 100644 --- a/apiphany-core/src/main/java/org/apiphany/client/http/AbstractHttpExchangeClient.java +++ b/apiphany-core/src/main/java/org/apiphany/client/http/AbstractHttpExchangeClient.java @@ -118,7 +118,7 @@ public static void addDefaultContentConverters(final List> c /** * Adds default value handlers to the header values chain. * - * @param headerValues the header values chain object + * @param headerValues the current header values chain object * @return the header values chain with default handlers added */ public static HeaderValues addDefaultHeaderValues(final HeaderValues headerValues) { @@ -327,7 +327,7 @@ protected String toJson(final ApiRequest apiRequest, final Object body) { * @param fallback the writer used when no content converter is selected * @return the encoded request body */ - protected String toString(T body, ApiMimeType mimeType, H headers, ToStringFunction fallback) { + protected String toString(final T body, final ApiMimeType mimeType, final H headers, final ToStringFunction fallback) { for (ContentConverter contentConverter : getContentConverters()) { if (contentConverter.isConvertible(mimeType, headers, getHeaderValuesChain())) { return contentConverter.toString(body, mimeType); @@ -386,12 +386,12 @@ protected int getMaxDecodedResponseBodySize() { /** * Checks declared content-length header against configured response-size limit. * - * @param the type of headers + * @param the type of headers * * @param headers response headers * @param maxBodySize max body size in bytes */ - protected void ensureContentLengthWithinLimit(final T headers, final int maxBodySize) { + protected void ensureContentLengthWithinLimit(final H headers, final int maxBodySize) { List contentLengthValues = getHeaderValues(HttpHeader.CONTENT_LENGTH, headers); if (Lists.isEmpty(contentLengthValues)) { return; diff --git a/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java b/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java index e306a4da..ef60207b 100644 --- a/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java +++ b/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java @@ -93,8 +93,7 @@ public ApacheHC5HttpExchangeClient() { public ApacheHC5HttpExchangeClient(final ClientProperties clientProperties) { super(clientProperties); ApacheHC5Library.verifyVersion(); - this.httpClient = ApacheHC5Clients.createClient(clientProperties, - this::customize, this::customize, this::customize); + this.httpClient = ApacheHC5Clients.createClient(clientProperties, this::customize, this::customize, this::customize); this.httpVersion = Nullables.nonNullOrDefault(this.httpVersion, HttpVersion.DEFAULT); } From ba7d7a91b57ec1593c7f435b68fe6cdff8265ced Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 2 Nov 2026 02:48:50 +0200 Subject: [PATCH 08/14] Keep header order in Apache and OkHttp clients too. --- .../http/ApacheHC5HttpExchangeClient.java | 4 +- .../http/ApacheHC5HttpExchangeClientTest.java | 3 + .../client/http/OkHttpExchangeClient.java | 88 ++++++++++++++++++- .../client/http/OkHttpExchangeClientTest.java | 35 ++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java diff --git a/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java b/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java index ef60207b..58195e5c 100644 --- a/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java +++ b/apiphany-httpclient5/src/main/java/org/apiphany/client/http/ApacheHC5HttpExchangeClient.java @@ -5,7 +5,7 @@ import java.io.Serializable; import java.net.URI; import java.nio.file.Path; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Predicate; @@ -380,7 +380,7 @@ public static HttpUriRequest toHttpUriRequest(final URI uri, final String httpMe * @return HTTP headers */ public static Map> toHttpHeadersMap(final Header[] headers) { - var httpHeaders = new HashMap>(); + var httpHeaders = new LinkedHashMap>(); for (Header header : headers) { Headers.addTo(httpHeaders, header.getName(), header.getValue()); } diff --git a/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java b/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java index 2f864f42..e32d5384 100644 --- a/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java +++ b/apiphany-httpclient5/src/test/java/org/apiphany/client/http/ApacheHC5HttpExchangeClientTest.java @@ -230,6 +230,9 @@ void shouldConvertHeaderArrayToMap() { assertThat(result.get("X-Custom"), equalTo(List.of("value1"))); assertThat(result.get("Accept"), equalTo(List.of("application/json"))); + var keys = result.keySet().iterator(); + assertThat(keys.next(), equalTo("X-Custom")); + assertThat(keys.next(), equalTo("Accept")); } @Test diff --git a/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java b/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java index f21f7fd9..94b35d97 100644 --- a/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java +++ b/apiphany-okhttp/src/main/java/org/apiphany/client/http/OkHttpExchangeClient.java @@ -2,12 +2,16 @@ import java.io.File; import java.io.InputStream; +import java.io.Serial; import java.io.Serializable; import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.function.Predicate; import java.util.function.Supplier; @@ -38,6 +42,7 @@ import org.morphix.lang.function.ThrowingSupplier; import okhttp3.Call; +import okhttp3.Headers; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -279,7 +284,7 @@ private static Charset charset(final ApiRequest apiRequest, final MediaType m */ protected ApiResponse buildResponse(final ApiRequest apiRequest, final Response response) { HttpStatus httpStatus = HttpStatus.fromCode(response.code()); - Map> headers = response.headers().toMultimap(); + Map> headers = toHttpHeadersMap(response.headers()); ensureContentLengthWithinLimit(headers, getMaxResponseBodySize()); Object responseBody = getResponseBody(apiRequest, response); @@ -294,6 +299,87 @@ protected ApiResponse buildResponse(final ApiRequest apiRequest, fi return buildResponse(apiRequest, httpStatus, headers, contentType, decodedBody); } + /** + * Transforms OkHttp headers to an insertion-ordered map of lowercase header names to values. Header names are + * lower-cased with {@link Locale#US} to preserve the behavior of OkHttp's {@code toMultimap()} and avoid + * machine-default locale differences. + * + * @param headers source headers + * @return HTTP headers in their first-seen order + */ + static Map> toHttpHeadersMap(final Headers headers) { + Map> result = new CaseInsensitiveStringLinkedHashMap<>(); + for (int i = 0; i < headers.size(); ++i) { + String name = headers.name(i).toLowerCase(Locale.US); + result.computeIfAbsent(name, key -> new ArrayList<>(2)).add(headers.value(i)); + } + return result; + } + + /** + * Insertion-ordered map used for OkHttp response headers. Header names are stored in lowercase and can be retrieved + * case-insensitively. + * + * @author Radu Sebastian LAZIN + */ + private static final class CaseInsensitiveStringLinkedHashMap extends LinkedHashMap { + + /** + * Serial version UID for serialization. + */ + @Serial + private static final long serialVersionUID = -1595053084733211507L; + + /** + * Constructs a new, empty map with insertion order. + */ + public CaseInsensitiveStringLinkedHashMap() { + // empty + } + + /** + * @see LinkedHashMap#get(Object) + */ + @Override + public V get(final Object key) { + return super.get(normalize(key)); + } + + /** + * @see LinkedHashMap#put(String, Object) + */ + @Override + public boolean containsKey(final Object key) { + return super.containsKey(normalize(key)); + } + + /** + * @see LinkedHashMap#put(String, Object) + */ + @Override + public V remove(final Object key) { + return super.remove(normalize(key)); + } + + /** + * @see LinkedHashMap#put(String, Object) + */ + @Override + public V getOrDefault(final Object key, final V defaultValue) { + return super.getOrDefault(normalize(key), defaultValue); + } + + /** + * Normalizes the given key to a lowercase string using {@link Locale#US}. Returns null if the key is not a string. + * + * @param key the key to normalize + * @return the normalized key, or null if the key is not a string + */ + private static String normalize(final Object key) { + return key instanceof String string ? string.toLowerCase(Locale.US) : null; + } + } + /** * Returns the response body converted to the target type. If the request is a stream, the response body is returned as * an input stream, otherwise it is returned as a byte array. diff --git a/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java b/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java new file mode 100644 index 00000000..b4883625 --- /dev/null +++ b/apiphany-okhttp/src/test/java/org/apiphany/client/http/OkHttpExchangeClientTest.java @@ -0,0 +1,35 @@ +package org.apiphany.client.http; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import okhttp3.Headers; + +/** + * Test class for {@link OkHttpExchangeClient}. + * + * @author Radu Sebastian LAZIN + */ +class OkHttpExchangeClientTest { + + @Test + void shouldConvertHeadersToAnInsertionOrderedMap() { + Headers headers = new Headers.Builder() + .add("Z-Header", "value1") + .add("A-Header", "value2") + .add("z-header", "value3") + .build(); + + Map> result = OkHttpExchangeClient.toHttpHeadersMap(headers); + + assertThat(new ArrayList<>(result.keySet()), equalTo(List.of("z-header", "a-header"))); + assertThat(result.get("z-header"), equalTo(List.of("value1", "value3"))); + assertThat(result.get("a-header"), equalTo(List.of("value2"))); + } +} From fb4c309eea0e27d7661660ff1a92d4f6938b5df2 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 2 Nov 2026 04:32:07 +0200 Subject: [PATCH 09/14] Header values should be case sensitive by default. --- .../main/java/org/apiphany/header/Headers.java | 2 +- .../java/org/apiphany/header/HeadersTest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apiphany-core/src/main/java/org/apiphany/header/Headers.java b/apiphany-core/src/main/java/org/apiphany/header/Headers.java index 33dff600..8fe0849e 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/Headers.java +++ b/apiphany-core/src/main/java/org/apiphany/header/Headers.java @@ -183,7 +183,7 @@ static boolean contains(final N headerName, final V headerValue, final Fu * @return true if the given headers contain the given header with the given value, false otherwise */ static boolean contains(final N headerName, final V headerValue, final Function> getValuesFunction) { - return contains(headerName, headerValue, getValuesFunction, String::equalsIgnoreCase); + return contains(headerName, headerValue, getValuesFunction, String::equals); } /** diff --git a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java index 69249c91..61b865a2 100644 --- a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java +++ b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java @@ -311,6 +311,21 @@ void shouldReturnTrueWhenCheckingExistingStringHeaderValueOnContains() { assertTrue(result); } + @Test + void shouldCompareHeaderValuesCaseSensitivelyByDefaultOnContains() { + boolean result = Headers.contains(N1, V1.toUpperCase(), headers); + + assertFalse(result); + } + + @Test + void shouldSupportCaseInsensitiveHeaderValueComparisonWhenExplicitlyRequestedOnContains() { + boolean result = Headers.contains(N1, V1.toUpperCase(), headerName -> Headers.get(headerName, headers), + String::equalsIgnoreCase); + + assertTrue(result); + } + @Test void shouldReturnFalseWhenCheckingNonExistingStringHeaderValueOnContains() { boolean result = Headers.contains(N1, "non-existing", headers); From fa1ad109fd8afea11e47d126332a4f4f7ecbfe7d Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 2 Nov 2026 11:14:51 +0200 Subject: [PATCH 10/14] Specify Jackson core version explicitely. --- apiphany-core/pom.xml | 24 ++++++++++++++++++++++++ apiphany-spring/pom.xml | 40 ++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/apiphany-core/pom.xml b/apiphany-core/pom.xml index 19e4fd72..8f7a035f 100644 --- a/apiphany-core/pom.xml +++ b/apiphany-core/pom.xml @@ -86,6 +86,22 @@ + + com.fasterxml.jackson.core + jackson-core + ${jackson2.version} + provided + true + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson2.version} + provided + true + + com.fasterxml.jackson.datatype jackson-datatype-jsr310 @@ -110,6 +126,14 @@ true + + tools.jackson.core + jackson-core + ${jackson3.version} + provided + true + + tools.jackson.core jackson-databind diff --git a/apiphany-spring/pom.xml b/apiphany-spring/pom.xml index e560dea9..b2474320 100644 --- a/apiphany-spring/pom.xml +++ b/apiphany-spring/pom.xml @@ -123,6 +123,14 @@ + + com.fasterxml.jackson.core + jackson-core + ${jackson2.version} + provided + true + + com.fasterxml.jackson.core jackson-databind @@ -137,12 +145,6 @@ ${jackson2.version} provided true - - - com.fasterxml.jackson.core - jackson-databind - - @@ -151,12 +153,6 @@ ${jackson2.version} provided true - - - com.fasterxml.jackson.core - jackson-databind - - @@ -165,12 +161,14 @@ ${jackson2.version} provided true - - - com.fasterxml.jackson.core - jackson-databind - - + + + + tools.jackson.core + jackson-core + ${jackson3.version} + provided + true @@ -187,12 +185,6 @@ ${jackson3.version} provided true - - - tools.jackson.core - jackson-databind - - From db3030f8059db66b7b47417a2b567eeb6f6349fa Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 2 Nov 2026 14:19:54 +0200 Subject: [PATCH 11/14] Refactor `Headers` to support case insensitive operations. --- .../java/org/apiphany/header/Headers.java | 52 ++++++++------ .../main/java/org/apiphany/lang/Strings.java | 16 +++++ .../java/org/apiphany/header/HeadersTest.java | 37 ++++++++++ .../java/org/apiphany/lang/StringsTest.java | 71 +++++++++++++++++++ 4 files changed, 154 insertions(+), 22 deletions(-) diff --git a/apiphany-core/src/main/java/org/apiphany/header/Headers.java b/apiphany-core/src/main/java/org/apiphany/header/Headers.java index 8fe0849e..a6208a4f 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/Headers.java +++ b/apiphany-core/src/main/java/org/apiphany/header/Headers.java @@ -11,6 +11,7 @@ import java.util.function.UnaryOperator; import org.apiphany.lang.Strings; +import org.morphix.lang.Nullables; import org.morphix.lang.collections.Lists; import org.morphix.lang.collections.Maps; @@ -38,6 +39,7 @@ static Map> of(final HeaderFunction... headerFunctions) { if (null == headerFunctions || 0 == headerFunctions.length) { return Collections.emptyMap(); } + // TODO: implement a case insensitive linked hash map var map = new LinkedHashMap>(); for (HeaderFunction headerFunction : headerFunctions) { headerFunction.addTo(map); @@ -114,7 +116,8 @@ static void addTo(final Map> existingHeaders, final case Object[] array -> Arrays.asList(array); default -> Collections.singletonList(headerValue); }; - List existing = existingHeaders.computeIfAbsent(headerName.toString(), k -> new ArrayList<>()); + String headerKey = resolveName(existingHeaders, headerName); + List existing = existingHeaders.computeIfAbsent(headerKey, k -> new ArrayList<>(1)); headerValues.forEach(hv -> { String stringValue = Strings.safeToString(hv); if (Strings.isNotEmpty(stringValue)) { @@ -126,6 +129,28 @@ static void addTo(final Map> existingHeaders, final }); } + /** + * Resolves the header name as {@link String} via case insensitive comparison. + * + * @param header name type + * + * @param headers + * @param headerName + * @return + */ + static String resolveName(final Map> headers, final N headerName) { + String headerKey = Strings.safeToString(headerName); + if (headers.containsKey(headerKey)) { + return headerKey; + } + for (String key : headers.keySet()) { + if (Strings.equalsIgnoreCase(key, headerKey)) { + return key; + } + } + return headerKey; + } + /** * Adds a header to existing headers with null value. The method preserves all header values, including duplicates so * that multiple values for the same header name are allowed and not overwritten. @@ -214,16 +239,8 @@ static boolean contains(final N headerName, final Map> if (Maps.isEmpty(headers)) { return false; } - String headerKey = Strings.safeToString(headerName); - if (headers.containsKey(headerKey)) { - return true; - } - for (Map.Entry> entry : headers.entrySet()) { - if (entry.getKey().equalsIgnoreCase(headerKey)) { - return true; - } - } - return false; + String headerKey = resolveName(headers, headerName); + return headers.containsKey(headerKey); } /** @@ -239,16 +256,7 @@ static List get(final N headerName, final Map> if (Maps.isEmpty(headers)) { return Collections.emptyList(); } - String headerKey = Strings.safeToString(headerName); - List values = headers.get(headerKey); - if (null != values) { - return values; - } - for (Map.Entry> entry : headers.entrySet()) { - if (entry.getKey().equalsIgnoreCase(headerKey)) { - return entry.getValue(); - } - } - return Collections.emptyList(); + String headerKey = resolveName(headers, headerName); + return Nullables.nonNullOrDefault(headers.get(headerKey), Collections::emptyList); } } diff --git a/apiphany-core/src/main/java/org/apiphany/lang/Strings.java b/apiphany-core/src/main/java/org/apiphany/lang/Strings.java index d7a48fdd..1fa23e3b 100644 --- a/apiphany-core/src/main/java/org/apiphany/lang/Strings.java +++ b/apiphany-core/src/main/java/org/apiphany/lang/Strings.java @@ -527,4 +527,20 @@ static boolean endsWithAny(final String input, final char... chars) { } return false; } + + /** + * Compares this {@code String} to another {@code String}, ignoring case considerations while any of the inputs can be + * {@code null}. + * + * @param a first string, can be {@code null} + * @param b second string, can be {@code null} + * @return true if the given strings are equal ignoring the case, false otherwise + * @see String#equalsIgnoreCase(String) + */ + static boolean equalsIgnoreCase(final String a, final String b) { + if (a == b) { + return true; + } + return null != a && a.equalsIgnoreCase(b); + } } diff --git a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java index 61b865a2..19a7465a 100644 --- a/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java +++ b/apiphany-core/src/test/java/org/apiphany/header/HeadersTest.java @@ -13,6 +13,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Stream; @@ -292,6 +293,31 @@ private static Stream provideNullAndEmptyValues() { Arguments.of("", ""), Arguments.of(" ", " ")); } + + @Test + void shouldPreserveOriginalHeaderNameWhenAddingWithDifferentCasing() { + Map> headers = new LinkedHashMap<>(); + + Headers.addTo(headers, "Content-Type", "application/json"); + Headers.addTo(headers, "content-type", "text/plain"); + + assertThat(headers.size(), equalTo(1)); + assertThat(Headers.get("CONTENT-TYPE", headers), equalTo(List.of("application/json", "text/plain"))); + assertThat(headers.keySet().iterator().next(), equalTo("Content-Type")); + } + + @Test + void shouldPreserveOriginalHeaderNameWhenExistingValueIsNull() { + Map> headers = new LinkedHashMap<>(); + headers.put("Content-Type", null); + + Headers.addTo(headers, "content-type", "text/plain"); + + assertThat(headers.size(), equalTo(1)); + assertThat(headers.keySet().iterator().next(), equalTo("Content-Type")); + assertThat(headers.get("Content-Type"), equalTo(List.of("text/plain"))); + assertThat(Headers.get("CONTENT-TYPE", headers), equalTo(List.of("text/plain"))); + } } @Nested @@ -407,6 +433,17 @@ void shouldReturnEmptyListOnGetForNonExistingHeader() { assertThat(headerValues, notNullValue()); assertThat(headerValues, hasSize(0)); } + + @Test + void shouldReturnEmptyListWhenExactHeaderNameHasNullValue() { + Map> headers = new LinkedHashMap<>(); + headers.put("Content-Type", null); + headers.put("content-type", List.of("text/plain")); + + assertThat(Headers.get("Content-Type", headers), equalTo(Collections.emptyList())); + assertThat(Headers.get("content-type", headers), equalTo(List.of("text/plain"))); + assertThat(Headers.get("CONTENT-TYPE", headers), equalTo(Collections.emptyList())); + } } @Nested diff --git a/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java b/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java index 83e7c8a3..4109c948 100644 --- a/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java +++ b/apiphany-core/src/test/java/org/apiphany/lang/StringsTest.java @@ -723,6 +723,77 @@ private static Stream provideValuesForRemoveWhitespaces() { Arguments.of("some\ttext\nwith\rdifferent\twhitespaces", "sometextwithdifferentwhitespaces")); } + @Nested + class EqualsIgnoreCaseTests { + + @Test + void shouldReturnTrueWhenBothReferencesAreNull() { + assertTrue(Strings.equalsIgnoreCase(null, null)); + } + + @Test + void shouldReturnTrueWhenBothReferencesAreTheSameInstance() { + String value = "Authorization"; + + assertTrue(Strings.equalsIgnoreCase(value, value)); + } + + @Test + void shouldReturnTrueWhenStringsMatchIgnoringCase() { + assertTrue(Strings.equalsIgnoreCase("Authorization", "authorization")); + assertTrue(Strings.equalsIgnoreCase("ABC", "abc")); + } + + @Test + void shouldReturnTrueWhenStringsAreExactlyEqual() { + assertTrue(Strings.equalsIgnoreCase(TEST_STRING, TEST_STRING)); + } + + @Test + void shouldReturnFalseWhenFirstStringIsNullAndSecondIsNot() { + assertFalse(Strings.equalsIgnoreCase(null, TEST_STRING)); + } + + @Test + void shouldReturnFalseWhenSecondStringIsNullAndFirstIsNot() { + assertFalse(Strings.equalsIgnoreCase(TEST_STRING, null)); + } + + @Test + void shouldReturnFalseWhenStringsDiffer() { + assertFalse(Strings.equalsIgnoreCase("Authorization", "Content-Type")); + assertFalse(Strings.equalsIgnoreCase("abc", "abd")); + } + + @ParameterizedTest + @MethodSource("provideEqualIgnoreCasePairs") + void shouldTreatPairsAsEqualIgnoringCase(final String first, final String second) { + assertTrue(Strings.equalsIgnoreCase(first, second)); + assertTrue(Strings.equalsIgnoreCase(second, first)); + } + + private static Stream provideEqualIgnoreCasePairs() { + return Stream.of( + Arguments.of("HTTP/1.1", "http/1.1"), + Arguments.of("UTF-8", "utf-8"), + Arguments.of("", "")); + } + + @ParameterizedTest + @MethodSource("provideUnequalIgnoreCasePairs") + void shouldTreatPairsAsUnequal(final String first, final String second) { + assertFalse(Strings.equalsIgnoreCase(first, second)); + assertFalse(Strings.equalsIgnoreCase(second, first)); + } + + private static Stream provideUnequalIgnoreCasePairs() { + return Stream.of( + Arguments.of("a", "b"), + Arguments.of("abc", "abcd"), + Arguments.of(" ", "")); + } + } + @Nested class EndsWithAnyTests { From ed9cca14d9ef3469a70b402d952b23ec9c809cd6 Mon Sep 17 00:00:00 2001 From: raduking Date: Mon, 2 Nov 2026 18:42:25 +0200 Subject: [PATCH 12/14] Document changes. --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c15b00f..653ec23b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,18 @@ - Added `HeaderValues.normalize(String)` and `HeaderValues.DANGEROUS_CHARACTERS` for dangerous-character normalization. - Added `Strings.isEnvelopedBy(String, char)` to check if a string starts and ends with the given character. - Added `Strings.isNotEnvelopedBy(String, char)` to check if a string does not start and end with the given character. +- Added `Headers.resolveName` to look up header names case-insensitively in a header map. +- Changed `Headers.get`, `Headers.contains`, and `Headers.addTo` to use case-insensitive header name resolution. +- Header value checks in `Headers.contains` remain case-sensitive by default; use the `BiPredicate` overload for other comparisons. +- Added `Strings.equalsIgnoreCase(String, String)` for null-safe case-insensitive string equality. +- Preserved header insertion order when sending requests in Apache HttpClient 5 and OkHttp clients. +- Pinned Jackson `jackson-core` optional dependencies in `apiphany-core` and `apiphany-spring` to `${jackson2.version}` and `${jackson3.version}`. - Added `install.sh` to install all Maven modules with test output redirected to reports. - Upgraded Jackson 2 to `2.21.8`. - Upgraded Jackson 3 to `3.1.8`. - Upgraded `logback-core` to `1.6.6`. - Upgraded `org.eclipse.jdt.core` to `3.47.0`. - Upgraded `code-format` to `1.1.0`. -- Pinned Jackson 2 and 3 optional dependencies in `apiphany-spring` to `${jackson2.version}` and `${jackson3.version}`. --- From c285d844cb1684b0e301f7e2bb8e1304a763e365 Mon Sep 17 00:00:00 2001 From: Radu Sebastian LAZIN Date: Mon, 2 Nov 2026 19:49:08 +0200 Subject: [PATCH 13/14] Added missing JavaDoc. --- .../src/main/java/org/apiphany/header/Headers.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apiphany-core/src/main/java/org/apiphany/header/Headers.java b/apiphany-core/src/main/java/org/apiphany/header/Headers.java index a6208a4f..d760e2f8 100644 --- a/apiphany-core/src/main/java/org/apiphany/header/Headers.java +++ b/apiphany-core/src/main/java/org/apiphany/header/Headers.java @@ -134,9 +134,9 @@ static void addTo(final Map> existingHeaders, final * * @param header name type * - * @param headers - * @param headerName - * @return + * @param headers existing headers + * @param headerName header name + * @return the resolved header name as {@link String} */ static String resolveName(final Map> headers, final N headerName) { String headerKey = Strings.safeToString(headerName); From f2cc602a35f72234d1177e09e35b1da61621b26d Mon Sep 17 00:00:00 2001 From: raduking Date: Tue, 3 Nov 2026 12:37:15 +0200 Subject: [PATCH 14/14] Upgraded `morphix-all` to `1.0.48`. --- CHANGELOG.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 653ec23b..949fc484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Preserved header insertion order when sending requests in Apache HttpClient 5 and OkHttp clients. - Pinned Jackson `jackson-core` optional dependencies in `apiphany-core` and `apiphany-spring` to `${jackson2.version}` and `${jackson3.version}`. - Added `install.sh` to install all Maven modules with test output redirected to reports. +- Upgraded `morphix-all` to `1.0.48`. - Upgraded Jackson 2 to `2.21.8`. - Upgraded Jackson 3 to `3.1.8`. - Upgraded `logback-core` to `1.6.6`. diff --git a/pom.xml b/pom.xml index d97831fc..12cf2a4c 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ - 1.0.47 + 1.0.48 1.17.2 2.21.8 3.1.8