Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Barcenas2017-12-20 03:35:53 -0500
committerMatthias Sohn2017-12-23 13:01:31 -0500
commit370659b44cac47ae9b3472c98b72acec43b14b9f (patch)
tree33419db264fc9061245b81c75c2cf3ac5a2208e3
parent4c7036fc57a096543c39b112c6291cded0bf382b (diff)
downloadegit-github-370659b44cac47ae9b3472c98b72acec43b14b9f.tar.gz
egit-github-370659b44cac47ae9b3472c98b72acec43b14b9f.tar.xz
egit-github-370659b44cac47ae9b3472c98b72acec43b14b9f.zip
Fix GitHubClient to always use responseContentType
The value of the GitHubRequest responseContentType field is supposed to be used as the HTTP Accept header for that particular GitHubRequest. This field exists because various endpoints in the GitHub API support multiple response media types. See: https://developer.github.com/v3/media/. This field is respected by GitHubClient's get(GitHubRequest) method, but this is *not* the case in getStream(GitHubRequest). The handling of the responseContentType field between these two very similar methods should definitely be consistent. Bug: 528982 Change-Id: Ie7964bf2337b4547ea602b0bfa3f2c20afc8df83 Signed-off-by: Christian Barcenas <christian@cbarcenas.com>
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
index 1a1285a0..5cb838c1 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -695,7 +695,12 @@ public class GitHubClient {
*/
public InputStream getStream(final GitHubRequest request)
throws IOException {
- return getResponseStream(createGet(request.generateUri()));
+ HttpURLConnection httpRequest = createGet(request.generateUri());
+ String accept = request.getResponseContentType();
+ if (accept != null) {
+ httpRequest.setRequestProperty(HEADER_ACCEPT, accept);
+ }
+ return getResponseStream(httpRequest);
}
/**

Back to the top