Commit ef6378ba authored by Tiago Cunha's avatar Tiago Cunha

Won't set an empty cookie

parent 26302a31
package chat.rocket.android.api.rest; package chat.rocket.android.api.rest;
import java.io.IOException; import java.io.IOException;
import chat.rocket.android.helper.TextUtils;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
...@@ -16,11 +17,15 @@ public class CookieInterceptor implements Interceptor { ...@@ -16,11 +17,15 @@ public class CookieInterceptor implements Interceptor {
@Override @Override
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
if (chain.request().url().host().equals(cookieProvider.getHostname())) { if (chain.request().url().host().equals(cookieProvider.getHostname())) {
final String cookie = cookieProvider.getCookie();
if (!TextUtils.isEmpty(cookie)) {
Request newRequest = chain.request().newBuilder() Request newRequest = chain.request().newBuilder()
.header("Cookie", cookieProvider.getCookie()) .header("Cookie", cookie)
.build(); .build();
return chain.proceed(newRequest); return chain.proceed(newRequest);
} }
}
return chain.proceed(chain.request()); return chain.proceed(chain.request());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment