aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/util')
-rw-r--r--src/main/java/com/juick/util/ActivityPubRequestInterceptor.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main/java/com/juick/util/ActivityPubRequestInterceptor.java b/src/main/java/com/juick/util/ActivityPubRequestInterceptor.java
index 138a3d09..65720910 100644
--- a/src/main/java/com/juick/util/ActivityPubRequestInterceptor.java
+++ b/src/main/java/com/juick/util/ActivityPubRequestInterceptor.java
@@ -17,21 +17,21 @@
package com.juick.util;
+import okhttp3.Interceptor;
+import okhttp3.Response;
+import org.jetbrains.annotations.NotNull;
import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpRequest;
-import org.springframework.http.client.ClientHttpRequestExecution;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
-import org.springframework.http.client.ClientHttpResponse;
-import org.springframework.lang.NonNull;
import java.io.IOException;
-public class ActivityPubRequestInterceptor implements ClientHttpRequestInterceptor {
-
+public class ActivityPubRequestInterceptor implements Interceptor {
+ @NotNull
@Override
- public @NonNull ClientHttpResponse intercept(HttpRequest request, @NonNull byte[] body,
- ClientHttpRequestExecution execution) throws IOException {
- request.getHeaders().set(HttpHeaders.USER_AGENT, "Juick/2.x");
- return execution.execute(request, body);
+ public Response intercept(@NotNull Interceptor.Chain chain) throws IOException {
+ var original = chain.request();
+ var request = original.newBuilder()
+ .addHeader(HttpHeaders.USER_AGENT, "Juick/2.x")
+ .method(original.method(), original.body());
+ return chain.proceed(request.build());
}
}