Use caching okhttp client for worldclient
This commit is contained in:
@@ -26,21 +26,30 @@
|
||||
package net.runelite.http.api.worlds;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class WorldClient
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(WorldClient.class);
|
||||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@Inject
|
||||
public WorldClient(OkHttpClient client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public WorldResult lookupWorlds() throws IOException
|
||||
{
|
||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
@@ -53,7 +62,7 @@ public class WorldClient
|
||||
.url(url)
|
||||
.build();
|
||||
|
||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||
try (Response response = client.newCall(request).execute())
|
||||
{
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user