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

Conversation

3rwww1
Copy link

@3rwww1 3rwww1 commented Jul 15, 2020

By default, java.net.HttpURLConnection HTTP Accept header is set to text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

This leads to Microsoft servers responding with a 203 status code and an HTML pages when uploading or downloading artifacts to Azure Artifacts.

Given that Maven also have a similar issue (text/html as the preferred response content-type), Microsoft has implemented a workaround that ignores the Accept header values when User-Agent is Apache Maven/*. However, this workaround is not implemented on their side for SBT.

This pull request sets HTTP Accept header to application/octet-stream, application/json, application/xml, */* to fix this behavior, as evidenced here:

https://dev.azure.com/aironek/sbt-test/_build/results?buildId=43&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=b60649db-91ed-45ce-b0dd-c9633ee87772

Given that the last component is */*, this shoud be backward-compatible with other serivces (Nexus, Artifactory, etc) that reply with different content-types.

@3rwww1
Copy link
Author

3rwww1 commented Jul 15, 2020

see sbt/sbt#5483

@3rwww1 3rwww1 force-pushed the fix/set-explicit-http-accept-header branch from d7e24c8 to f5f00b0 Compare July 15, 2020 13:43
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit fbc4f58 into sbt:2.3.x-sbt Jul 15, 2020
@dwijnand
Copy link
Member

This leads to Microsoft servers responding with a 203 status code and an HTML pages when uploading or downloading artifacts to Azure Artifacts.

Does that mean it fixes sbt/sbt#5492 too, @3rwww1?

@milanvdm
Copy link

milanvdm commented Oct 6, 2020

@dwijnand Ever got a response to your question? :)

@dwijnand
Copy link
Member

dwijnand commented Oct 6, 2020

No. But I'm leaning towards yes, because more often than not you hear back when it's still broken... 🙂

@eed3si9n
Copy link
Member

eed3si9n commented Oct 6, 2020

Re: sbt/sbt#5492, the issue is mostly about being able to resolve artifacts out of Azure DevOps Maven, so maybe tweaking Ivy might help for ThisBuild / useCoursier := false case, but as a general issue it would likely need coursier/coursier#1649.

@3rwww1
Copy link
Author

3rwww1 commented Oct 8, 2020

@dwijnand unfortunately I'm still not sure, I'm still jury-rigging around the issue with ThisBuild / useCoursier := false

I'll try and test with coursier when I have some free time, I guess that all coursier need is to "set Accept: header to something other than text/html", as per MS dev team instructions. Don't know if coursier does set those headers properly though, last time I checked it seemed it didn't.

@3rwww1 3rwww1 deleted the fix/set-explicit-http-accept-header branch October 8, 2020 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants