Don't overwrite okhttp ua if already set

If the request has its own UA set, don't overwrite it with the default
RuneLite one. This has to be an interceptor and not a network
interceptor so that it runs prior to the okhttp BridgeInteceptor, which
is what sets the default okhttp ua.
This commit is contained in:
Adam
2022-04-28 18:56:00 -04:00
parent 1eda2c3658
commit c40b33a1e9

View File

@@ -434,9 +434,15 @@ public class RuneLite
{
OkHttpClient.Builder builder = new OkHttpClient.Builder()
.pingInterval(30, TimeUnit.SECONDS)
.addNetworkInterceptor(chain ->
.addInterceptor(chain ->
{
Request userAgentRequest = chain.request()
Request request = chain.request();
if (request.header("User-Agent") != null)
{
return chain.proceed(request);
}
Request userAgentRequest = request
.newBuilder()
.header("User-Agent", USER_AGENT)
.build();