feed: use caching okhttp client

This commit is contained in:
Adam
2019-09-27 22:19:46 -04:00
parent 1fa8409265
commit 2af98eacfc
2 changed files with 14 additions and 2 deletions

View File

@@ -28,8 +28,10 @@ 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;
@@ -39,6 +41,14 @@ public class FeedClient
{
private static final Logger logger = LoggerFactory.getLogger(FeedClient.class);
private final OkHttpClient client;
@Inject
public FeedClient(OkHttpClient client)
{
this.client = client;
}
public FeedResult lookupFeed() throws IOException
{
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
@@ -51,7 +61,7 @@ public class FeedClient
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
try (Response response = client.newCall(request).execute())
{
if (!response.isSuccessful())
{