Merge branch 'master' into add-file-source-bytes

This commit is contained in:
ncaq 2018-04-24 12:21:56 +09:00
commit 74ce4c57ff
3 changed files with 28 additions and 3 deletions

View File

@ -1,7 +1,11 @@
## 1.6.4
## 1.6.5
* Add `fileSourceByteString` [#1503](https://github.com/yesodweb/yesod/pull/1503)
## 1.6.4
* Add `addContentDispositionFileName` [#1504](https://github.com/yesodweb/yesod/pull/1504)
## 1.6.3
* Add missing export for `SubHandlerFor`

View File

@ -119,6 +119,7 @@ module Yesod.Core.Handler
, setHeader
, replaceOrAddHeader
, setLanguage
, addContentDispositionFileName
-- ** Content caching and expiration
, cacheSeconds
, neverExpires
@ -782,6 +783,26 @@ deleteCookie a = addHeaderInternal . DeleteCookie (encodeUtf8 a) . encodeUtf8
setLanguage :: MonadHandler m => Text -> m ()
setLanguage = setSession langKey
-- | Set attachment file name.
--
-- Allows Unicode characters by encoding to UTF-8.
-- Some modurn browser parse UTF-8 characters with out encoding setting.
-- But, for example IE9 can't parse UTF-8 characters.
-- This function use
-- <https://tools.ietf.org/html/rfc6266 RFC 6266>(<https://tools.ietf.org/html/rfc5987 RFC 5987>)
--
-- @since 1.6.4
addContentDispositionFileName :: MonadHandler m => T.Text -> m ()
addContentDispositionFileName fileName
= addHeader "Content-Disposition" $ rfc6266Utf8FileName fileName
-- | <https://tools.ietf.org/html/rfc6266 RFC 6266> Unicode attachment filename.
--
-- > rfc6266Utf8FileName (Data.Text.pack "€")
-- "attachment; filename*=UTF-8''%E2%82%AC"
rfc6266Utf8FileName :: T.Text -> T.Text
rfc6266Utf8FileName fileName = "attachment; filename*=UTF-8''" `mappend` decodeUtf8 (H.urlEncode True (encodeUtf8 fileName))
-- | Set an arbitrary response header.
--
-- Note that, while the data type used here is 'Text', you must provide only
@ -1369,7 +1390,7 @@ fileSource = transPipe liftResourceT . fileSourceRaw
-- > do
-- > fileByteString <- fileSourceByteString fileInfo
--
-- @since 1.6.4
-- @since 1.6.5
fileSourceByteString :: MonadResource m => FileInfo -> m S.ByteString
fileSourceByteString fileInfo = L.toStrict <$> runConduit (fileSource fileInfo .| sinkLazy)

View File

@ -1,5 +1,5 @@
name: yesod-core
version: 1.6.4
version: 1.6.5
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>