Description
When making HTTP requests with no headers, the Java HttpClient throws an IllegalArgumentException: wrong number, 0, of parameters error.
Stack Trace
Caused by: java.lang.IllegalArgumentException: wrong number, 0, of parameters
at java.net.http/jdk.internal.net.http.common.Utils.newIAE(Utils.java:326)
at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.headers(HttpRequestBuilderImpl.java:135)
at java.net.http/jdk.internal.net.http.HttpRequestBuilderImpl.headers(HttpRequestBuilderImpl.java:43)
Expected Behavior
Wirespec should handle requests with no headers gracefully, without throwing an exception.
Current Workaround
Adding a dummy header to ensure the headers array is not empty:
.let { it + arrayOf("test", "value") }
Context
This issue was discovered while integrating the bunq-sdk built on wirespec. The workaround is currently necessary to prevent crashes when no headers are required for the API request.
References
Description
When making HTTP requests with no headers, the Java HttpClient throws an
IllegalArgumentException: wrong number, 0, of parameterserror.Stack Trace
Expected Behavior
Wirespec should handle requests with no headers gracefully, without throwing an exception.
Current Workaround
Adding a dummy header to ensure the headers array is not empty:
Context
This issue was discovered while integrating the bunq-sdk built on wirespec. The workaround is currently necessary to prevent crashes when no headers are required for the API request.
References