Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
snooze/src/Snooze/Core.hs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (29 sloc)
942 Bytes
This file contains 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 NoImplicitPrelude #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE CPP #-} | |
module Snooze.Core ( | |
httpGo | |
, httpGo' | |
) where | |
import Data.ByteString.Lazy as BSL | |
import Network.HTTP.Client | |
import P | |
import System.IO | |
-- Eventually we will want/need to have sensible retries/timeouts here | |
httpGo :: Manager -> Request -> IO (Response BSL.ByteString) | |
httpGo mgr req = | |
httpLbs req { | |
#if MIN_VERSION_http_client(0,5,0) | |
#else | |
checkStatus = _checkStatusIgnore, | |
#endif | |
-- Never follow redirects - should always be done by the consumer explicitly if appropriate | |
redirectCount = 0 | |
} mgr | |
where | |
-- A stupid default of http-client is to throw exceptions for non-200 | |
_checkStatusIgnore _ _ _ = Nothing | |
httpGo' :: Request -> IO (Response BSL.ByteString) | |
httpGo' req = | |
newManager defaultManagerSettings >>= flip httpGo req |