I am having an issue when setting the Authorization header using setRequestProperty
. It appears that the total length of the property value cannot exceed 80 bytes.
if(headerData != null) {
for (Pair pair : headerData) {
urlConnection.setRequestProperty(pair.first.toString(),pair.second.toString());
}
}
The pair is:
"Authorization", "Basic TW9oYW5ATmV0UmVhY2gtTW9oYW5zLUFQR3JvdXA6TW9oYW5ATmV0UmVhY2gtTW9oYW5zLUFQR3Jv dXA=\n"
The error is: java.lang.IllegalArgumentException: Unexpected char 0x0a at 82 in header value
If I reduce the total length of the value to be under 80, it works fine.