Last active
December 16, 2015 18:08
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# 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