tldr; url escape your url string, replace the spaces with %20, and it
will work. You can use the urlencode jinja2 filter if you like but it
will change how you store the elements of your url slightly:
- vars:
pydev_url_scheme: http
pydev_url:
freefr.dl.sourceforge.net/project/pydev/pydev/PyDev 4.4.0/
pydev_bundle: PyDev 4.4.0.zip
tasks:
- get_url: url="{{pydev_url_scheme}}://{{ pydev_url
|urlencode()}}/{{ pydev_bundle|urlencode() }}" dest=/tmp/pydev
In depth:
I can duplicate and the problem would be solved by doing a
urllib.quote of the path element of the url string(which replaces
spaces with "%20") .... Not sure whether we should do that or not. It
would be a change in behaviour that breaks things for people who
already escape their url. In my experience, tools commonly accept
spaces and escape if they are not already escaped. Libraries commonly
force the user to escape themselves.
Experimenting shows that curl does not automatically escape spaces
(although its interaction with this server is somewhat surprising...
it's returning a 302 to a page saying the mirror failed rather than a
404). Manually changing the spaces to %20 is required.
Looks like wget attempts to be smart. I haven't worked out the exact
algorithm it's using but it seems to automatically escape spaces. It
escaped a percent not followed by a number. But it did not escape a
percent followed by a number. So with wget, both
"
http://freefr.dl.sourceforge.net/project/pydev/pydev/PyDev 4.4.0/"
and "
http://freefr.dl.sourceforge.net/project/pydev/pydev/PyDev%204.4.0/"
work but if you have a file named ugly%42file.html, the url you'd have
to create for that would have to manually escape the percent sign like
this: ugly%2542file.html.
So for ansible... we could take a few different paths i think:
* Do nothing -- we match curl's behaviour here. People can just use %
escaping for the urls they specify and the jinja iflter helps with
that.
* Do something like wget and escape spaces and certain uses of
percents. This will break backwards compat but probably for only a
few people.
* Add a parameter to get_url to let the user specify whether we should
escape or not defaulting to no escape. this is fully backwards
compatible and lets the user choose whether to escape or not.
Willing to hear some discussion and a pull request to implement a
change based on that.
-Toshio
On Tue, Nov 17, 2015 at 5:13 AM, Nathan Sowatskey
>
https://groups.google.com/d/msgid/ansible-project/6e136fcb-364a-4ad9-bd48-831993d9e397%40googlegroups.com.