Skip to content

Conversation

@swankjesse
Copy link
Collaborator

This doesn't completely support ISO-8859-1 headers; instead they will most likely
be mangled when they are decoded as UTF-8. If we decide we absolutely must support
ISO-8859-1 here we can do that in another change. (I'm not currently enthusiastic
about this idea.)

But this does prevent OkHttp from crashing when it encounters non-ASCII characters
in headers for HTTP/2, SPDY, and cached responses.

Closes: #1998

This doesn't completely support ISO-8859-1 headers; instead they will most likely
be mangled when they are decoded as UTF-8. If we decide we absolutely must support
ISO-8859-1 here we can do that in another change. (I'm not currently enthusiastic
about this idea.)

But this does prevent OkHttp from crashing when it encounters non-ASCII characters
in headers for HTTP/2, SPDY, and cached responses.

Closes: #1998
@BlaineRideCell
Copy link

I am still seeing this issue with OkHttp, version 3.6, and Retrofit 2.2.0. Here is my stacktrace:

03-13 12:08:17.730 18865-19003/com.my.app.dev E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Process:com.my.app.dev, PID: 18865 java.lang.IllegalArgumentException: Unexpected char 0x10c at 0 in x-locale value: Česká republika at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:320) at okhttp3.Headers$Builder.set(Headers.java:300) at okhttp3.Request$Builder.header(Request.java:164) at com.ridecell.rest.RetrofitClient$1.intercept(RetrofitClient.java:125) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:129) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

@manjunath143
Copy link

manjunath143 commented Nov 18, 2019

@swankjesse
I just tried passing ISO-8859-1 non-ASCII string as header.
String header="";
try {
String s="ääääääääääääääääääää";
header=new String(s.getBytes("UTF-8"), "ISO-8859-1")
}catch (UnsupportedEncodingException e){
e.getStackTrace();
}

But it did not work. Just curious to know if okhttp supports this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IllegalArgumentException in Headers$Builder.checkNameAndValue() for content-disposition filename response header

5 participants