Merge branch 'master' of github.com:yesodweb/yesod

This commit is contained in:
Michael Snoyman 2018-04-26 11:20:26 +03:00
commit 07df43f207
No known key found for this signature in database
GPG Key ID: A048E8C057E86876
8 changed files with 53 additions and 8 deletions

View File

@ -43,3 +43,4 @@ extra-deps:
- websockets-0.12.3.1
- th-abstraction-0.2.6.0
- persistent-template-2.5.3.1
- th-lift-instances-0.1.11

View File

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

View File

@ -118,6 +118,7 @@ module Yesod.Core.Handler
, setHeader
, replaceOrAddHeader
, setLanguage
, addContentDispositionFileName
-- ** Content caching and expiration
, cacheSeconds
, neverExpires
@ -780,6 +781,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

View File

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

View File

@ -1,3 +1,7 @@
## 1.6.3
Add performMethod
[#1502](https://github.com/yesodweb/yesod/pull/1502)
## 1.6.2
* Add byLabel-related functions like byLabelContain

View File

@ -54,6 +54,7 @@ module Yesod.Test
, get
, post
, postBody
, performMethod
, followRedirect
, getLocation
, request
@ -894,9 +895,7 @@ getRequestCookies = do
post :: (Yesod site, RedirectUrl site url)
=> url
-> YesodExample site ()
post url = request $ do
setMethod "POST"
setUrl url
post = performMethod "POST"
-- | Perform a POST request to @url@ with the given body.
--
@ -925,9 +924,22 @@ postBody url body = request $ do
get :: (Yesod site, RedirectUrl site url)
=> url
-> YesodExample site ()
get url = request $ do
setMethod "GET"
setUrl url
get = performMethod "GET"
-- | Perform a request using a given method to @url@.
--
-- @since 1.6.3
--
-- ==== __Examples__
--
-- > performMethod "DELETE" HomeR
performMethod :: (Yesod site, RedirectUrl site url)
=> ByteString
-> url
-> YesodExample site ()
performMethod method url = request $ do
setMethod method
setUrl url
-- | Follow a redirect, if the last response was a redirect.
-- (We consider a request a redirect if the status is

View File

@ -124,6 +124,9 @@ main = hspec $ do
yit "tests1b" $ do
get ("/foo" :: Text)
statusIs 404
yit "tests1c" $ do
performMethod "DELETE" ("/" :: Text)
statusIs 200
ydescribe "tests2" $ do
yit "type-safe URLs" $ do
get $ LiteAppRoute []

View File

@ -1,5 +1,5 @@
name: yesod-test
version: 1.6.2
version: 1.6.3
license: MIT
license-file: LICENSE
author: Nubis <nubis@woobiz.com.ar>