question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IllegalArgumentException: Unexpected char ... in header value: ... at com.squareup.okhttp.Headers$Builder.checkNameAndValue (Headers.java:295)

See original GitHub issue

I get crash reports like that:

java.lang.IllegalArgumentException: Unexpected char 0x43a at 101 in header value: Mozilla/5.0 (Linux; U; Android 4.1.2; ru-ru; PMP7170B3G_DUO Build/JZO54K) AppleWebKit/534.30 (KHTML, как Gecko) Version/4.0 МобильныйSafari/534.30
    at com.squareup.okhttp.Headers$Builder.checkNameAndValue (Headers.java:295)
    at com.squareup.okhttp.Headers$Builder.set (Headers.java:275)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.setRequestProperty (HttpURLConnectionImpl.java:526)
    <some 3rd library code I don't have access to>

Seems to happen due to non-ASCII chars in header value. Similar to #1998. But #1998 is about response header and my smacktrace is about request header.

Thank you!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:40 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
pbertschcommented, Dec 11, 2015

I used only NO_WRAP and it seems to work at the moment. I will try to write a test case with the Base64.DEFAULT flag only.

Patrick

https://www.streetlife.com.mx powered by Alpha Wave Systems On Dec 11, 2015 15:16, “Kannan Goundan” notifications@github.com wrote:

@pbertsch https://github.com/pbertsch: What encoding does the server say you should use? Is there public documentation for the server you’re sending requests to? (Aside: OkHttp should be fine with both DEFAULT and URL_SAFE – both use only printable ASCII characters.)

— Reply to this email directly or view it on GitHub https://github.com/square/okhttp/issues/2016#issuecomment-164049334.

1reaction
rohitkum28commented, Mar 31, 2020

@rohitkum28 If you ask and self answer on stackoverflow, I’ll bump up both. 25 points right there 😃

I did ask the question on StackOverflow and now that I know the answer I added it on Stackoverflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

okhttp: IllegalArgumentException: Unexpected char 0xea
We can use addUnsafeNonAscii to solve this issue. Below is the simple code snippet of it. Headers headers = new Headers.Builder() .
Read more >
java.lang.IllegalArgumentException: Unexpected char 0x4e00 ...
IllegalArgumentException : Unexpected char 0x4e00 at 25 in header value: ... checkNameAndValue(Headers.java:295) at com.squareup.okhttp.
Read more >
HttpClient exception unexpected char in header value - MSDN
What we are seeing is that when making calls using HttpClient to our API an exception is thrown when the http client parses...
Read more >
Apache Nifi - On Passing Apikey In Invokehttp Processor It Is ...
IllegalArgumentException : Unexpected char in header value: at com.squareup.okhttp.HeadersBuilder.checkNameAndValue Headers.java:.
Read more >
Unexpected char 0x131 at 23 in User-Agent value: selenium ...
... IllegalArgumentException: Unexpected char ... in header value: ... at com.squareup.okhttp.Headers$Builder.checkNameAndValue (Headers.java:295) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found