Closed madebr closed 4 years ago
I reproduced the error. The server is blocking the request, I'm going to investigate a bit more.
Related to https://github.com/conan-io/conan/issues/7349
Changing the user-agent
header works (Allowed thanks to https://github.com/conan-io/conan/pull/7390), the server is blocking the default from the python requests library:
tools.download("http://angelcode.com/angelscript/sdk/files/angelscript_2.34.0.zip", filename="angelscript_2.34.0.zip", headers={"User-Agent": "foo"})
Totally related. https://github.com/conan-io/conan/issues/7349#issuecomment-657875347 even used the same url :man_facepalming:
I don't get it. How do I overwrite the user-agent when I calll conan-install?
Hi @Wuestenschiff
You don't change the user-agent of Conan globally for all requests. A specific recipe can use a different agent if necessary in its tools.download()
call in the source()
method for example, if the server is picky about the agent. But this needs to be edited in the recipe.
@memsharded Well then I understood but this is a problem when server just decide to block requests and brick builds. (like cloudlfare in https://github.com/conan-io/conan-center-index/issues/7478)
I think a possility to change this for clients would be very appreciated in such situations
@lasote @jgsogo, it seems the python-requests
user agent is the one generally having issues in some servers. Is it that necessary? Maybe we could just remove it?
I don't have any reason to keep it.
Hi! I'm not sure if this is related to the user-agent.... but if it fixes the issue, IMO it is safe to remove the python-requests
part.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406
The HyperText Transfer Protocol (HTTP) 406 Not Acceptable client error response code indicates that the server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers, and that the server is unwilling to supply a default representation.
Proactive content negotiation headers include:
Accept Accept-Encoding Accept-Language
I created https://github.com/conan-io/conan/issues/9760 and assigned it to the release.
I have this problem when packaging arm toolchains at https://github.com/conan-io/conan-center-index/pull/6822, Adding the following http headers fixes it:
from conans import __version__ as conan_version
tools.download(**self._sources_dict, filename="archive.tar.xz",
headers={"User-Agent": "Conan v{}".format(conan_version)})
When (trying to) downloading the angelscript sdk at http://angelcode.com/angelscript/sdk/files/angelscript_2.34.0.zip using conan, I get a http error 406.
Using
wget "http://angelcode.com/angelscript/sdk/files/angelscript_2.34.0.zip"
works.Environment Details (include every applicable attribute)
logs