Move okhttp client from http-api
The client has been recreated with a new builder off of the http-api client for awhile anyway since runelite-client has multiple other requirements (caching, tls, etc). This fully moves creation of the okhttp client into both http-service and runelite-client separately. I've kept the CLIENT field in http-api for now since a few external plugins depend on it currently.
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
|
||||
<properties>
|
||||
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
|
||||
<git.commit.id.abbrev>nogit</git.commit.id.abbrev>
|
||||
<git.dirty>false</git.dirty>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -154,6 +156,13 @@
|
||||
<build>
|
||||
<finalName>runelite-${project.version}</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -164,6 +173,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<configuration>
|
||||
<!-- Prevent reloading resources since it doesn't work when the resources are also filtered -->
|
||||
<addResources>false</addResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.kongchen</groupId>
|
||||
@@ -215,6 +228,42 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>2.2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>query-git-info</id>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
|
||||
<gitDescribe>
|
||||
<skip>true</skip>
|
||||
</gitDescribe>
|
||||
<includeOnlyProperties>
|
||||
<includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
|
||||
<includeOnlyProperty>git.dirty</includeOnlyProperty>
|
||||
</includeOnlyProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Automatic expansion of properties in configuration https://docs.spring.io/spring-boot/docs/2.0.0.M7/reference/html/howto-properties-and-configuration.html#howto-automatic-expansion-maven -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<configuration>
|
||||
<delimiters>
|
||||
<delimiter>@</delimiter>
|
||||
</delimiters>
|
||||
<useDefaultDelimiters>false</useDefaultDelimiters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.naming.NamingException;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
@@ -39,10 +40,10 @@ import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.RuneLiteAPI;
|
||||
import net.runelite.http.service.util.InstantConverter;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.impl.StaticLoggerBinder;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -200,9 +201,24 @@ public class SpringBootWebApplication extends SpringBootServletInitializer
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OkHttpClient okHttpClient()
|
||||
public OkHttpClient okHttpClient(
|
||||
@Value("${runelite.version}") String version,
|
||||
@Value("${runelite.commit}") String commit,
|
||||
@Value("${runelite.dirty}") boolean dirty
|
||||
)
|
||||
{
|
||||
return RuneLiteAPI.CLIENT;
|
||||
final String userAgent = "RuneLite/" + version + "-" + commit + (dirty ? "+" : "");
|
||||
return new OkHttpClient.Builder()
|
||||
.pingInterval(30, TimeUnit.SECONDS)
|
||||
.addNetworkInterceptor(chain ->
|
||||
{
|
||||
Request userAgentRequest = chain.request()
|
||||
.newBuilder()
|
||||
.header("User-Agent", userAgent)
|
||||
.build();
|
||||
return chain.proceed(userAgentRequest);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
|
||||
@@ -98,6 +98,7 @@ public class AccountService
|
||||
private final String oauthClientId;
|
||||
private final String oauthClientSecret;
|
||||
private final String oauthCallback;
|
||||
private final String runeliteVersion;
|
||||
private final AuthFilter auth;
|
||||
private final RedisPool jedisPool;
|
||||
|
||||
@@ -107,6 +108,7 @@ public class AccountService
|
||||
@Value("${oauth.client-id}") String oauthClientId,
|
||||
@Value("${oauth.client-secret}") String oauthClientSecret,
|
||||
@Value("${oauth.callback}") String oauthCallback,
|
||||
@Value("${runelite.version}") String runeliteVersion,
|
||||
AuthFilter auth,
|
||||
RedisPool jedisPool
|
||||
)
|
||||
@@ -115,6 +117,7 @@ public class AccountService
|
||||
this.oauthClientId = oauthClientId;
|
||||
this.oauthClientSecret = oauthClientSecret;
|
||||
this.oauthCallback = oauthCallback;
|
||||
this.runeliteVersion = runeliteVersion;
|
||||
this.auth = auth;
|
||||
this.jedisPool = jedisPool;
|
||||
|
||||
@@ -143,7 +146,7 @@ public class AccountService
|
||||
{
|
||||
State state = new State();
|
||||
state.setUuid(uuid);
|
||||
state.setApiVersion(RuneLiteAPI.getVersion());
|
||||
state.setApiVersion(runeliteVersion);
|
||||
|
||||
OAuth20Service service = new ServiceBuilder()
|
||||
.apiKey(oauthClientId)
|
||||
|
||||
@@ -33,6 +33,9 @@ mongo:
|
||||
database: runelite
|
||||
|
||||
runelite:
|
||||
version: @project.version@
|
||||
commit: @git.commit.id.abbrev@
|
||||
dirty: @git.dirty@
|
||||
# Twitter client for feed
|
||||
twitter:
|
||||
consumerkey:
|
||||
|
||||
Reference in New Issue
Block a user