# get\_url (and maybe later uri): honor content-disposition

**URL:** <https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647>\
**Category:** Ansible Developer\
**Created:** [October 9, 2013, 7:28pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647 "2013-10-09T19:28:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tin\_Tvrtkovic](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@Tin\_Tvrtkovic](https://forum.ansible.com/u/Tin_Tvrtkovic)\
**Post date:** [October 9, 2013, 7:28pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/1 "2013-10-09T19:28:27Z")

</div>

Hi,

oh cool, a new list.

The get\_url and uri modules don’t respect file names from content disposition headers. While creating a playbook for deploying Maven artifacts from our Nexus instance today I wished they did. 🙂

Both modules clearly state:

```auto
If I(dest) is a directory, the basename of the file on the remote server will be used.

```

I’m willing to put in some effort to make get\_url (and later maybe uri) respect the content disposition header for determining the resulting filename.

What I’m proposing is:

- If you specify a filename for the destination, the file goes to that file name, no questions asked (just like now)
- If you specify a directory, and the response contains a content disposition header of the form ‘Content-Disposition: attachment; filename=“fname.ext”’, a file named ‘fname.ext’ is created in the directory you specified, with the content from the URL
- If you specify a directory and there is no content disposition header with the given format in the response, we fall back to the current behavior

If I wrote this, could I get it merged?

Cheers

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [October 9, 2013, 7:36pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/2 "2013-10-09T19:36:53Z")

</div>

> If I wrote this, could I get it merged?

Sounds good to me.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [October 9, 2013, 7:48pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/3 "2013-10-09T19:48:01Z")

</div>

Yes, this seems totally reasonable. Look forward to your pull request 🙂

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [October 10, 2013, 7:15am UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/4 "2013-10-10T07:15:33Z")

</div>

> The get\_url and uri modules don't respect file names from content  
> disposition headers. While creating a playbook for deploying Maven  
> artifacts from our Nexus instance today I wished they did. 🙂

The uri module will check for redirects and look at the Location Header  
though​​, and download from that if follow\_redirects = True, or you can  
register the redirected url from there and download it with get\_url (if the  
artifact is too big memory-wise for uri)

I actually wrote that feature especially for using with Nexus, which yields  
a 302 when downloading through the rest interface.

Serge

---

<div class="post-metadata">

**Author:** ![Tin\_Tvrtkovic](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@Tin\_Tvrtkovic](https://forum.ansible.com/u/Tin_Tvrtkovic)\
**Post date:** [November 2, 2013, 4:30pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/5 "2013-11-02T16:30:28Z")

</div>

Here we go: [https://github.com/ansible/ansible/pull/4785](https://github.com/ansible/ansible/pull/4785).

If I can get this merged, I’ll do the uri module next.

Cheers

---

<div class="post-metadata">

**Author:** ![Tin\_Tvrtkovic](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@Tin\_Tvrtkovic](https://forum.ansible.com/u/Tin_Tvrtkovic)\
**Post date:** [November 14, 2013, 5:44pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/6 "2013-11-14T17:44:26Z")

</div>

Can someone take a look at this? I’ve included some test scenarios for verification in the comments.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 15, 2013, 5:29pm UTC](https://forum.ansible.com/t/get-url-and-maybe-later-uri-honor-content-disposition/13647/7 "2013-11-15T17:29:53Z")

</div>

you have a ticket filed, it’s in queue – no reason to email the entire list.

Support customers will of course get higher priority but we are attacking lots of different things for everyone.

All priority bugs were closed down to 0 last week and we are focusing on pull requests for a while.

– Michael
