haskell-servant/servant

Invalid HTTP headers

Open

#770 geöffnet am 19. Juni 2017

Auf GitHub ansehen
 (7 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Haskell (422 Forks)batch import
help wanted

Repository-Metriken

Stars
 (1.953 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5h 49m) (2 gemergte PRs in 30 T)

Beschreibung

I'm not sure if there's a type-safe way of enforcing valid HTTP header names, but servant currently allows header names to have spaces which can break break Chrome.

More information can be found in a wai issue at https://github.com/yesodweb/wai/issues/628.

Example

{-# LANGUAGE DataKinds         #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators     #-}

module Main where

import           Network.Wai
import           Network.Wai.Handler.Warp
import           Servant
import           Data.Text

type HelloAPI = Get '[PlainText] (Headers '[Header "A A" Text] Text)

server :: Server HelloAPI
server = return $ addHeader "foo" $ "Hello, world!"

helloApi :: Proxy HelloAPI
helloApi = Proxy

app :: Application
app = serve helloApi server

main :: IO ()
main = run 80 app

Contributor Guide