Add preview media type header explicitly

This commit is contained in:
Kohsuke Kawaguchi
2016-08-05 20:47:08 -07:00
parent 6a356c82a5
commit 59324b0082
3 changed files with 18 additions and 8 deletions

View File

@@ -141,7 +141,9 @@ public class GHLicense extends GHObject {
protected synchronized void populate() throws IOException {
if (description!=null) return; // already populated
root.retrieve().to(url, this);
root.retrieve()
.withHeader("Accept","application/vnd.github.drax-preview+json")
.to(url, this);
}
@Override

View File

@@ -856,10 +856,7 @@ public class GHRepository extends GHObject {
*/
@Preview @Deprecated
public GHLicense getLicense() throws IOException{
return root.retrieve()
.withHeader("Accept","application/vnd.github.drax-preview+json")
.to(getApiTailUrl("license"), GHContentWithLicense.class)
.wrap(this).license;
return getLicenseContent_().license;
}
/**
@@ -872,7 +869,14 @@ public class GHRepository extends GHObject {
*/
@Preview @Deprecated
public GHContent getLicenseContent() throws IOException {
return root.retrieve().to(getApiTailUrl("license"), GHContent.class).wrap(this);
return getLicenseContent_();
}
@Preview @Deprecated
private GHContentWithLicense getLicenseContent_() throws IOException {
return root.retrieve()
.withHeader("Accept","application/vnd.github.drax-preview+json")
.to(getApiTailUrl("license"), GHContentWithLicense.class).wrap(this);
}
/**

View File

@@ -353,7 +353,9 @@ public class GitHub {
public PagedIterable<GHLicense> listLicenses() throws IOException {
return new PagedIterable<GHLicense>() {
public PagedIterator<GHLicense> _iterator(int pageSize) {
return new PagedIterator<GHLicense>(retrieve().asIterator("/licenses", GHLicense[].class, pageSize)) {
return new PagedIterator<GHLicense>(retrieve()
.withHeader("Accept","application/vnd.github.drax-preview+json")
.asIterator("/licenses", GHLicense[].class, pageSize)) {
@Override
protected void wrapUp(GHLicense[] page) {
for (GHLicense c : page)
@@ -376,7 +378,9 @@ public class GitHub {
*/
@Preview @Deprecated
public GHLicense getLicense(String key) throws IOException {
return retrieve().to("/licenses/" + key, GHLicense.class);
return retrieve()
.withHeader("Accept","application/vnd.github.drax-preview+json")
.to("/licenses/" + key, GHLicense.class);
}
/**