-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected char 0x0a at 28 in header value #1153
Comments
0x0a is a newline character which is forbidden in a header (by OkHttp, not Retrofit). Ensure these control characters are stripped before passing them to Retrofit. |
Thanks. So that means "=" is causing all the trouble here? |
No, there's an invisible newline character ( |
Thanks. .trim() did the job. :) |
@prashantwosti Another way could be: |
0x0a is a newline character which is forbidden in a header. Solution would be to make sure that these characters are stripped off before sending the encoded value as header. Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); this avoids wrapping with a platform specific newline character(s). |
This is my header value:
I99Uy+HjG5PpEhmi8vZgm0W7KDQ=
When I try to pass that value via parameter, retrofit is throwing an error.
I/: Failure: Unexpected char 0x0a at 28 in header value: I99Uy+HjG5PpEhmi8vZgm0W7KDQ=
But when I add the same header value as hard-coded string in API interface class, it works.
This works:
This does not:
How do I fix it?
Thanks
The text was updated successfully, but these errors were encountered: