Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set explicit HTTP Accept header to avoid text/html #40

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/java/org/apache/ivy/util/url/BasicURLHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public InputStream openStream(URL url) throws IOException {
conn = url.openConnection();
conn.setRequestProperty("User-Agent", "Apache Ivy/" + Ivy.getIvyVersion());
conn.setRequestProperty("Accept-Encoding", "gzip,deflate");
conn.setRequestProperty("Accept", "application/octet-stream, application/json, application/xml, */*");
if (conn instanceof HttpURLConnection) {
HttpURLConnection httpCon = (HttpURLConnection) conn;
if (!checkStatusCode(url, httpCon)) {
Expand Down Expand Up @@ -199,6 +200,7 @@ public void download(URL src, File dest, CopyProgressListener l) throws IOExcept
srcConn = src.openConnection();
srcConn.setRequestProperty("User-Agent", "Apache Ivy/" + Ivy.getIvyVersion());
srcConn.setRequestProperty("Accept-Encoding", "gzip,deflate");
srcConn.setRequestProperty("Accept", "application/octet-stream, application/json, application/xml, */*");
if (srcConn instanceof HttpURLConnection) {
HttpURLConnection httpCon = (HttpURLConnection) srcConn;
int status = httpCon.getResponseCode();
Expand Down Expand Up @@ -260,6 +262,7 @@ public void upload(File source, URL dest, CopyProgressListener l) throws IOExcep
conn.setDoOutput(true);
conn.setRequestMethod("PUT");
conn.setRequestProperty("User-Agent", "Apache Ivy/" + Ivy.getIvyVersion());
conn.setRequestProperty("Accept", "application/octet-stream, application/json, application/xml, */*");
conn.setRequestProperty("Content-type", "application/octet-stream");
conn.setRequestProperty("Content-length", Long.toString(source.length()));
conn.setInstanceFollowRedirects(true);
Expand Down
1 change: 1 addition & 0 deletions src/java/org/apache/ivy/util/url/IvyAuthenticator.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected PasswordAuthentication getPasswordAuthentication() {

// sbt change, driven by https://github.com/sbt/sbt/issues/2366
if (c == null) {
Message.debug("authentication: requesting prompt: " + getRequestingPrompt());
c = CredentialsStore.INSTANCE.getCredentials(null, getRequestingHost());
Message.debug("authentication: k='"
+ Credentials.buildKey(null, getRequestingHost()) + "' c='" + c + "'");
Expand Down