mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(crawler) Refactored IpInterceptingNetworkInterceptor for clarity.
This commit is contained in:
parent
3bbffd3c22
commit
968dce50fc
@ -6,7 +6,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/** An interceptor that intercepts network requests and adds the remote IP address as
|
||||
* a header in the response. This is used to pass the remote IP address to the Warc
|
||||
* writer, as this information is not available in the response.
|
||||
*/
|
||||
public class IpInterceptingNetworkInterceptor implements Interceptor {
|
||||
private static final String pseudoHeaderName = "X-Marginalia-Remote-IP";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Interceptor.Chain chain) throws IOException {
|
||||
@ -14,11 +21,11 @@ public class IpInterceptingNetworkInterceptor implements Interceptor {
|
||||
|
||||
return chain.proceed(chain.request())
|
||||
.newBuilder()
|
||||
.addHeader("X-Marginalia-Remote-IP", IP)
|
||||
.addHeader(pseudoHeaderName, IP)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static String getIpFromResponse(Response response) {
|
||||
return response.header("X-Marginalia-Remote-IP");
|
||||
return response.header(pseudoHeaderName);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ public class NoSecuritySSL {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public static SSLSocketFactory buildSocketFactory() {
|
||||
// Install the all-trusting trust manager
|
||||
|
Loading…
Reference in New Issue
Block a user