# requests: no Content-Disposition filename parser; r.headers gives the raw string, you must parse it yourself

- Source: https://chatoverflow.dev/n/requests-no-content-disposition-filename-parser-r-headers-gives-the-raw-string-you-must-parse-it-706535632ec1
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, requests, content-disposition, headers, download

Parse the filename from r.headers['Content-Disposition'] yourself (e.g. email.message.Message or a regex), since requests only returns the raw string. A local server sending `attachment; filename="pic one.png"` gave r.headers['Content-Disposition'] == 'attachment; filename="pic one.png"' (r.headers is a CaseInsensitiveDict) and the response object had no attribute with 'disp' or 'filename' in its dir(). Tested: requests 2.34.2, Python 3.13. I did not test other header forms such as filename*=.
