private static final Logger LOG = Loggers.get(GithubApplicationHttpClientImpl.class);
private static final Pattern NEXT_LINK_PATTERN = Pattern.compile("<([^<]+)>; rel=\"next\"");
- private static final String GITHUB_API_VERSION_JSON = "application/vnd.github.v3+json";
- private static final String ANTIOPE_PREVIEW_JSON = "application/vnd.github.antiope-preview+json";
- private static final String MACHINE_MAN_PREVIEW_JSON = "application/vnd.github.machine-man-preview+json";
+ private static final String GH_API_VERSION_HEADER = "X-GitHub-Api-Version";
+ private static final String GH_API_VERSION = "2022-11-28";
private final OkHttpClient client;
Request.Builder url = new Request.Builder().url(toAbsoluteEndPoint(appUrl, endPoint));
if (token != null) {
url.addHeader("Authorization", token.getAuthorizationHeaderPrefix() + " " + token);
- url.addHeader("Accept", String.format("%s, %s, %s", ANTIOPE_PREVIEW_JSON, MACHINE_MAN_PREVIEW_JSON, GITHUB_API_VERSION_JSON));
+ url.addHeader(GH_API_VERSION_HEADER, GH_API_VERSION);
}
return url;
}
@RunWith(DataProviderRunner.class)
public class GithubApplicationHttpClientImplTest {
- private static final String BETA_API_HEADER = "application/vnd.github.antiope-preview+json, " +
- "application/vnd.github.machine-man-preview+json, " +
- "application/vnd.github.v3+json";
+ private static final String GH_API_VERSION_HEADER = "X-GitHub-Api-Version";
+ private static final String GH_API_VERSION = "2022-11-28";
+
@Rule
public MockWebServer server = new MockWebServer();
assertThat(recordedRequest.getMethod()).isEqualTo("GET");
assertThat(recordedRequest.getPath()).isEqualTo(randomEndPoint);
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo("token " + accessToken.getValue());
- assertThat(recordedRequest.getHeader("Accept")).isEqualTo(BETA_API_HEADER);
+ assertThat(recordedRequest.getHeader(GH_API_VERSION_HEADER)).isEqualTo(GH_API_VERSION);
}
@Test
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
assertThat(recordedRequest.getPath()).isEqualTo(randomEndPoint);
assertThat(recordedRequest.getHeader("Authorization")).isEqualTo("token " + accessToken.getValue());
- assertThat(recordedRequest.getHeader("Accept")).isEqualTo(BETA_API_HEADER);
+ assertThat(recordedRequest.getHeader(GH_API_VERSION_HEADER)).isEqualTo(GH_API_VERSION);
}
@Test