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

Support Content-Disposition of inline in send_file() #1432

Closed
wants to merge 2 commits into from

Conversation

d5ve
Copy link
Contributor

@d5ve d5ve commented Feb 23, 2018

When called with a "filename" arg, send_file() sets the
Content-Disposition header type to "attachment". This triggers a "Save"
dialogue in some browsers when opening a link in a new tab or window.

  • Add an optional "content_disposition" argument to send_file() which can be
    set to "inline" to have the browser display the file inline.

  • Add a note to the manual about this new behaviour.

  • Add tests for "attachment" and "inline" behaviours.

When called with a "filename" arg, send_file() sets the
Content-Disposition header type to "attachment". This triggers a "Save"
dialogue in some browsers when opening a link in a new tab or window.

+ Add an optional "content_disposition" argument to send_file() which can be
set to "inline" to have the browser display the file inline.

+ Add a note to the manual about this new behaviour.

+ Add tests for "attachment" and "inline" behaviours.
@d5ve
Copy link
Contributor Author

d5ve commented Feb 23, 2018

The AppVeyor CI failure doesn't seem related to the contents of the PR.

It looks like Strawberry perl can't install Dist::Zilla, so the build fails.

@veryrusty
Copy link
Member

This looks like a good improvement to me. @d5ve we try and support perl 5.8 if its at all possible.
Any change you could modify the PR to remove the use of exclusive or (//) ?

This would only behave differently if the caller passed in '' or 0 as
the `content_disposition` arg, so the functionality should be the same.
@d5ve
Copy link
Contributor Author

d5ve commented Mar 9, 2018

I changed from // to || which has basically the same functionality in this case.

@cromedome
Copy link
Contributor

@d5ve - I really like this improvement. Thanks for the change to help us support 5.8 as well. This gets a 👍 from me.

@SysPete
Copy link
Member

SysPete commented Mar 17, 2018

Nice change 👍

@cromedome
Copy link
Contributor

Merged, thank you!

@cromedome cromedome closed this Mar 17, 2018
cromedome added a commit that referenced this pull request Apr 10, 2018
    [ BUG FIXES ]
    * GH #1304: Fix the order by which config files are loaded, independently
      of their filename extension (Alberto Simões, Russell @veryrusty Jenkins)
    * GH #1400: Fix infinite recursion with exceptions that use circular
      references. (Andre Walker)
    * GH #1430: Fix `dancer2 gen` from source directory when Dancer2 not
      installed. (Tina @perlpunk Müller - Tina)
    * GH #1434: Add `validate_id` method to verify a session id before
      requesting the session engine fetch it from its data store.
      (Russell @veryrusty Jenkins)
    * GH #1435, #1438: Allow XS crush_cookie methods to return an arrayref
      of values. (Russell @veryrusty Jenkins)
    * GH #1090, #1406: Replace HTTP::Body with HTTP::Entity::Parser in
      Dancer2::Core::Request. (Russell @veryrusty Jenkins)
    * GH #1443: Update copyright year (Joseph Frazer)
    * GH #1445: Use latest HTTP::Headers::Fast (Russell @veryrusty Jenkins)

    [ ENHANCEMENTS ]
    * GH #1432: Support Content-Disposition of inline in
      send_file() (Dave Webb)
    * PR #1433: Verbose testing in AppVeyor (Graham Knop)
    * PR #1354: TemplateToolkit template engine will log (at debug level)
      if a template is not found. (Kiel R Stirling, Russell @veryrusty Jenkins)

    [ DOCUMENTATION ]
    * GH #1317: Document serializer configuration (sdeseille)
    * PR #1426: Move performance improvement information from Migration guide
      to Deployment (Pedro Melo)
cromedome added a commit that referenced this pull request Apr 20, 2018
    [ BUG FIXES ]
    * GH #1090, #1406: Replace HTTP::Body with HTTP::Entity::Parser in
      Dancer2::Core::Request. (Russell @veryrusty Jenkins)
    * GH #1292: Fix multiple attribute definitions within Plugins
      (Nigel Gregoire)
    * GH #1304: Fix the order by which config files are loaded, independently
      of their filename extension (Alberto Simões, Russell @veryrusty Jenkins)
    * GH #1400: Fix infinite recursion with exceptions that use circular
      references. (Andre Walker)
    * GH #1430: Fix `dancer2 gen` from source directory when Dancer2 not
      installed. (Tina @perlpunk Müller - Tina)
    * GH #1434: Add `validate_id` method to verify a session id before
      requesting the session engine fetch it from its data store.
      (Russell @veryrusty Jenkins)
    * GH #1435, #1438: Allow XS crush_cookie methods to return an arrayref
      of values. (Russell @veryrusty Jenkins)
    * GH #1443: Update copyright year (Joseph Frazer)
    * GH #1445: Use latest HTTP::Headers::Fast (Russell @veryrusty Jenkins)
    * PR #1447: Fix missing build requires (Mohammad S Anwar)

    [ ENHANCEMENTS ]
    * PR #1354: TemplateToolkit template engine will log (at debug level)
      if a template is not found. (Kiel R Stirling, Russell @veryrusty Jenkins)
    * GH #1432: Support Content-Disposition of inline in
      send_file() (Dave Webb)
    * PR #1433: Verbose testing in AppVeyor (Graham Knop)

    [ DOCUMENTATION ]
    * GH #1314: Documentation tweaks (David Precious)
    * GH #1317: Document serializer configuration (sdeseille)
    * GH #1386: Add Hello World example (Gabor Szabo)
    * PR #1408: List project development resources (Steve Dondley)
    * PR #1426: Move performance improvement information from Migration guide
      to Deployment (Pedro Melo)
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