Skip to content

Commit 61e8dd0

Browse files
committed
Revert "Workaround for hub4j#669 - remove If-Modified-Since header"
This reverts commit 90d7fea.
1 parent 90d7fea commit 61e8dd0

2 files changed

Lines changed: 2 additions & 36 deletions

File tree

src/main/java/org/kohsuke/github/extras/okhttp3/ObsoleteUrlFactory.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import okio.Okio;
2020
import okio.Pipe;
2121
import okio.Timeout;
22-
import org.jetbrains.annotations.NotNull;
2322

2423
/*
2524
* Copyright (C) 2014 Square, Inc.
@@ -618,18 +617,7 @@ private Call buildCall() throws IOException {
618617
OkHttpClient.Builder clientBuilder = client.newBuilder();
619618
clientBuilder.interceptors().clear();
620619
clientBuilder.interceptors().add(UnexpectedException.INTERCEPTOR);
621-
622620
clientBuilder.networkInterceptors().clear();
623-
624-
// network interceptors are generally not allowed
625-
// (probably buggy when used with this hacked in adapter)
626-
// but we have to use this one to handle github issue:
627-
// https://github.com/isaacs/github/issues/692
628-
// #669 in this project
629-
if (client.cache() != null && getUseCaches()) {
630-
clientBuilder.addNetworkInterceptor(new OkHttpConnector.RemoveIfModifiedSinceRequestHeader());
631-
}
632-
633621
clientBuilder.networkInterceptors().add(networkInterceptor);
634622

635623
// Use a separate dispatcher so that limits aren't impacted. But use the same executor service!

src/main/java/org/kohsuke/github/extras/okhttp3/OkHttpConnector.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package org.kohsuke.github.extras.okhttp3;
22

3-
import okhttp3.Interceptor;
4-
import okhttp3.Request;
5-
import okhttp3.Response;
63
import okhttp3.CacheControl;
74
import okhttp3.ConnectionSpec;
85
import okhttp3.OkHttpClient;
@@ -54,18 +51,12 @@ public OkHttpConnector(OkHttpClient client, int cacheMaxAge) {
5451
OkHttpClient.Builder builder = client.newBuilder();
5552

5653
builder.connectionSpecs(TlsConnectionSpecs());
57-
58-
if (cacheMaxAge >= 0 && client.cache() != null) {
54+
this.client = builder.build();
55+
if (cacheMaxAge >= 0 && this.client != null && this.client.cache() != null) {
5956
maxAgeHeaderValue = new CacheControl.Builder().maxAge(cacheMaxAge, TimeUnit.SECONDS).build().toString();
60-
// HttpURLConnection does not support networkInterceptors, so this would not work
61-
// However, we hacked ObsoleteUrlFactory to do this automatically for us.
62-
// builder.addNetworkInterceptor(new RemoveIfModifiedSinceRequestHeader());
6357
} else {
6458
maxAgeHeaderValue = null;
6559
}
66-
67-
this.client = builder.build();
68-
6960
this.urlFactory = new ObsoleteUrlFactory(this.client);
7061
}
7162

@@ -88,17 +79,4 @@ public HttpURLConnection connect(URL url) throws IOException {
8879
private List<ConnectionSpec> TlsConnectionSpecs() {
8980
return Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT);
9081
}
91-
92-
static class RemoveIfModifiedSinceRequestHeader implements Interceptor {
93-
@Override
94-
public Response intercept(Chain chain) throws IOException {
95-
Request currentRequest = chain.request();
96-
if (currentRequest.header("If-Modified-Since") != null) {
97-
currentRequest = currentRequest.newBuilder()
98-
.removeHeader("If-Modified-Since")
99-
.build();
100-
}
101-
return chain.proceed(currentRequest);
102-
}
103-
}
10482
}

0 commit comments

Comments
 (0)