Skip to content

Instantly share code, notes, and snippets.

@MichaelXavier
Last active December 16, 2015 18:08
Show Gist options
  • Select an option

  • Save MichaelXavier/5475167 to your computer and use it in GitHub Desktop.

Select an option

Save MichaelXavier/5475167 to your computer and use it in GitHub Desktop.
http-client seems to hang indefinitely waiting on the content from some servers when they return 204 no content.
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Network.Http.Client
main :: IO ()
main = get ("http://localhost:4568/") printStatus
-- prints the status then hangs forever
where printStatus resp stream = print $ getStatusCode resp
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Snap.Http.Server
import Snap.Core
import Data.Monoid
import Web.Scotty
import Network.Wai
import Network.HTTP.Types.Status
main = snapMain
snapMain = httpServe (setPort port defaultConfig) $ route routes
where routes = [("/", root)]
root = modifyResponse $ setResponseStatus 204 "No Content"
-- happens here too. i think the server is leaving the connection open and http-streams needs to close it on 204s?
scottyMain = scotty port $ do
get "/" $ do
status noContent204
port = 4568
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment