Commit ef6378ba authored by Tiago Cunha's avatar Tiago Cunha

Won't set an empty cookie

parent 26302a31
package chat.rocket.android.api.rest;
import java.io.IOException;
import chat.rocket.android.helper.TextUtils;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
......@@ -16,10 +17,14 @@ public class CookieInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
if (chain.request().url().host().equals(cookieProvider.getHostname())) {
Request newRequest = chain.request().newBuilder()
.header("Cookie", cookieProvider.getCookie())
.build();
return chain.proceed(newRequest);
final String cookie = cookieProvider.getCookie();
if (!TextUtils.isEmpty(cookie)) {
Request newRequest = chain.request().newBuilder()
.header("Cookie", cookie)
.build();
return chain.proceed(newRequest);
}
}
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