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.

Error Headers Unexpected char

See original GitHub issue
Fatal Exception: java.lang.IllegalArgumentException: Unexpected char 0xae at 47 in user-agent value: Dalvik/1.6.0 (Linux; U; Android 4.4.2; INCO AIR® Build/KOT49H)
       at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:283)
       at okhttp3.Headers$Builder.add(Headers.java:233)
       at com.facebook.react.modules.network.NetworkingModule.extractHeaders(NetworkingModule.java:469)
       at com.facebook.react.modules.network.NetworkingModule.sendRequest(NetworkingModule.java:180)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:319)
       at com.facebook.react.bridge.NativeModuleRegistry$ModuleDefinition.call(NativeModuleRegistry.java:187)
       at com.facebook.react.bridge.NativeModuleRegistry.call(NativeModuleRegistry.java:62)
       at com.facebook.react.bridge.CatalystInstanceImpl$NativeModulesReactCallback.call(CatalystInstanceImpl.java:432)
       at com.facebook.react.bridge.queue.NativeRunnableDeprecated.run(NativeRunnableDeprecated.java)
       at android.os.Handler.handleCallback(Handler.java:808)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
       at android.os.Looper.loop(Looper.java:193)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
       at java.lang.Thread.run(Thread.java:841)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
swankjessecommented, Aug 19, 2016

Strictly speaking this is a problem with Facebook’s NetworkingModule.java. The fix is a method like so:

  /** Returns {@code s} with control characters and non-ASCII characters replaced with '?'. */
  public static String toHumanReadableAscii(String s) {
    for (int i = 0, length = s.length(), c; i < length; i += Character.charCount(c)) {
      c = s.codePointAt(i);
      if (c > '\u001f' && c < '\u007f') continue;

      Buffer buffer = new Buffer();
      buffer.writeUtf8(s, 0, i);
      for (int j = i; j < length; j += Character.charCount(c)) {
        c = s.codePointAt(j);
        buffer.writeUtf8CodePoint(c > '\u001f' && c < '\u007f' ? c : '?');
      }
      return buffer.readUtf8();
    }
    return s;
  }
0reactions
shefengcommented, Nov 21, 2022

i also have this problem when my user-agent is 美图心语 3.1 (iPhone; iOS 16.1.1; zh_CN)

Read more comments on GitHub >

github_iconTop Results From Across the Web

OkHttp3 java.lang.IllegalArgumentException: Unexpected ...
I am writing an apps that publishes a http header. The apps crashed because a right single quoted character. This is the stack...
Read more >
Unexpected char 0x0a in header value when using OkHttp ...
Android : Unexpected char 0x0a in header value when using OkHttp client in Android [ Beautify Your Computer ...
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 >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
This string has to be valid JSON and will throw this error if incorrect syntax ... JSON.parse: unexpected character // at line 1...
Read more >
Unexpected character while processing gzip payload
This error is expected for DataWeave as the encoding header makes no difference at that point, it is an HTTP header meant for...
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