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

added: addContentDispositionFileName #1504

Merged
merged 5 commits into from
Apr 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions yesod-core/Yesod/Core/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ module Yesod.Core.Handler
, setHeader
, replaceOrAddHeader
, setLanguage
, addContentDispositionFileName
-- ** Content caching and expiration
, cacheSeconds
, neverExpires
Expand Down Expand Up @@ -780,6 +781,14 @@ deleteCookie a = addHeaderInternal . DeleteCookie (encodeUtf8 a) . encodeUtf8
setLanguage :: MonadHandler m => Text -> m ()
setLanguage = setSession langKey

-- | Set attachment file name.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a ChangeLog entry, cabal version bump, and a @since comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinked that wait other pull request.
However, If I should write before it, I write.
So I write.

--
-- allow UTF-8 character.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably say something like: "Allows Unicode characters by encoding to UTF-8"

addContentDispositionFileName :: MonadHandler m => T.Text -> m ()
addContentDispositionFileName name
= addHeader "Content-Disposition" $
"attachment; filename*=UTF-8''" `mappend` decodeUtf8 (H.urlEncode True (encodeUtf8 name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this syntax before. Can you reference the relevant spec that details how this is supposed to work in a comment?


-- | Set an arbitrary response header.
--
-- Note that, while the data type used here is 'Text', you must provide only
Expand Down