-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Recover gracefully instead of throwing IllegalCharsetNameException #2677
Comments
It looks like your server is returning a header like this:
Unfortunately according to RFC 822, use of single quotes isn’t valid in a media type parameter. Instead the content type should be this:
Please ask your server team to fix their broken response headers. I’m unsure what action OkHttp should take here. Probably our best bet is to see how web browsers like Chrome and Firefox handle invalid charsets and do likewise. |
thank you |
Chrome treats single quotes interchangeably with double quotes. Safari and Firefox ignore the malformed charset parameter and detect it from the content. |
It's what Chrome does. Firefox and Safari ignore it. I'd love to ignore it, but in our API that really just means the caller needs to handle an InvalidCharsetNameException and nobody is expecting that. Closes: #2677
It's what Chrome does. Firefox and Safari ignore it. I'd love to ignore it, but in our API that really just means the caller needs to handle an InvalidCharsetNameException and nobody is expecting that. Closes: #2677
Wrong data from server
#1.
`
<title>系统发生错误</title> <style type="text/css">` #2557 4920-5047/arkui.live W/System.err: java.nio.charset.IllegalCharsetNameException: 'utf-8'
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at java.nio.charset.Charset.checkCharsetName(Charset.java:197)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at java.nio.charset.Charset.forName(Charset.java:295)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at okhttp3.MediaType.charset(MediaType.java:103)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at okhttp3.ResponseBody.charset(ResponseBody.java:159)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at okhttp3.ResponseBody.string(ResponseBody.java:154)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at arkui.live.dao.LoadDataUtil$1.onResponse(LoadDataUtil.java:82)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-29 12:47:49.557 4920-5047/arkui.live W/System.err: at java.lang.Thread.run(Thread.java:818)
The text was updated successfully, but these errors were encountered: