hack 2009.4.51 → 2009.4.52
raw patch · 4 files changed
+41/−16 lines, 4 filesdep −utf8-stringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: utf8-string
API changes (from Hackage documentation)
- Hack: type Map = [(String, String)]
- Hack: type MiddleWare = Middleware
- Hack: type Stream = String -> IO ()
- Hack: Env :: RequestMethod -> String -> String -> String -> String -> Int -> Map -> [Int] -> Hack_UrlScheme -> String -> HackErrors -> Bool -> Bool -> Bool -> Map -> Env
+ Hack: Env :: RequestMethod -> String -> String -> String -> String -> Int -> [(String, String)] -> [Int] -> Hack_UrlScheme -> String -> HackErrors -> Bool -> Bool -> Bool -> [(String, String)] -> Env
- Hack: Response :: Int -> Map -> String -> Response
+ Hack: Response :: Int -> [(String, String)] -> String -> Response
- Hack: custom :: Env -> Map
+ Hack: custom :: Env -> [(String, String)]
- Hack: headers :: Response -> Map
+ Hack: headers :: Response -> [(String, String)]
- Hack: http :: Env -> Map
+ Hack: http :: Env -> [(String, String)]
- Hack: type HackErrors = Stream
+ Hack: type HackErrors = String -> IO ()
Files
- changelog.md +12/−0
- hack.cabal +2/−2
- readme.md +21/−0
- src/Hack.hs +6/−14
changelog.md view
@@ -1,3 +1,15 @@+2009.4.52+---------++### Feature++* Remove useless type alias++### Fix++* Default error stream should take utf8 string++ 2009.4.51 ---------
hack.cabal view
@@ -1,5 +1,5 @@ Name: hack-Version: 2009.4.51+Version: 2009.4.52 Build-type: Simple Synopsis: a sexy Haskell Webserver Interface Description:@@ -20,7 +20,7 @@ library ghc-options: -Wall- build-depends: base, data-default >= 0.2, utf8-string >= 0.3.4+ build-depends: base, data-default >= 0.2 hs-source-dirs: src/ exposed-modules: Hack
readme.md view
@@ -163,6 +163,23 @@ Please read [The Rack interface specification](http://rack.rubyforge.org/doc/files/SPEC.html). +Tip+---++### encoding can be tricky+1. hack uses utf8 bytes for IO+2. when dealing with html, sometimes, e.g. using template haskell, you have to + 1. encode unicode string using: `escape_unicode_xml` for plain text+ 2. before rendering to response body, do `unescape_unicode_xml`+ 3. then use `u2b` to convert unicode string to utf8 bytes, and push to response+3. see, xml encoding and utf8 byte encoding are different, so we need+ to convert twice+4. why bother `unescape_unicode_xml` at all? since we want the user+ to be able to see unicode chars when viewing source!+5. these helpers are in `hack-contrib` and `mps`+6. the default error stream in hack takes unicode string as input. It will be+ fixed in the next release.+ Links ----- @@ -178,4 +195,8 @@ * [Rack](http://rack.rubyforge.org/ ) * [Rack wiki](http://wiki.github.com/rack/rack) * [rack-contrib](http://github.com/rack/rack-contrib/tree/master)+* [Chris Done's Blog @Kibro](http://chrisdone.com/blog/tags/Kibro.html) * [Hyena](http://github.com/tibbe/hyena/tree/master)+* [Happstack](http://happstack.com/)+* [Jinjing's Blog @Hack](http://jinjing.easymic.com/tag/Hack)+* [Bamboo blog engine](https://github.com/nfjinjing/bamboo/tree)
src/Hack.hs view
@@ -4,11 +4,10 @@ module Hack where import Data.Default-import System.IO.UTF8-import System.IO (stderr)+import System.IO version :: [Int]-version = [2009, 4, 51]+version = [2009, 4, 52] data RequestMethod = OPTIONS@@ -23,12 +22,8 @@ data Hack_UrlScheme = HTTP | HTTPS deriving (Show, Eq) -type Map = [(String, String)]--type Stream = String -> IO ()- -- | customizable error stream-type HackErrors = Stream+type HackErrors = String -> IO () instance Show HackErrors where show _ = "HackErrors"@@ -40,7 +35,7 @@ , query_string :: String -- ^ The portion of the request URL that follows the ?, if any. May be empty , server_name :: String -- ^ When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used , server_port :: Int -- ^ preference to SERVER_NAME for reconstructing the request URL. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required. - , http :: Map -- ^ Variables corresponding to the client-supplied HTTP request headers+ , http :: [(String, String)] -- ^ Variables corresponding to the client-supplied HTTP request headers , hack_version :: [Int] -- ^ The Array [0,1], representing this version of Hack , hack_url_scheme :: Hack_UrlScheme -- ^ HTTP or HTTPS, depending on the request URL , hack_input :: String -- ^ body of the request@@ -48,13 +43,13 @@ , hack_multithread :: Bool -- ^ true if the application object may be simultaneously invoked by another thread in the same process, false otherwise. , hack_multiprocess :: Bool -- ^ true if an equivalent application object may be simultaneously invoked by another process, false otherwise. , hack_run_once :: Bool -- ^ true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar). - , custom :: Map -- ^ any non HTTP standard header+ , custom :: [(String, String)] -- ^ any non HTTP standard header } deriving (Show) data Response = Response { status :: Int -- ^ must be greater than or equal to 100. - , headers :: Map -- ^ The header must not contain a Status key, contain keys with : or newlines in their name, contain keys names that end in - or _, but only contain keys that consist of letters, digits, _ or - and start with a letter. The values of the header must be Strings, consisting of lines (for multiple header values) seperated by \"\\n\". The lines must not contain characters below 037. + , headers :: [(String, String)] -- ^ The header must not contain a Status key, contain keys with : or newlines in their name, contain keys names that end in - or _, but only contain keys that consist of letters, digits, _ or - and start with a letter. The values of the header must be Strings, consisting of lines (for multiple header values) seperated by \"\\n\". The lines must not contain characters below 037. , body :: String -- ^ body of the response } deriving (Show)@@ -75,6 +70,3 @@ type Application = Env -> IO Response type Middleware = Application -> Application---- compatibility-type MiddleWare = Middleware