Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
stack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- run: stack dot --global-hints --resolver nightly --lock-file read-write
- uses: actions/cache@v4
with:
Expand Down Expand Up @@ -47,14 +47,27 @@ jobs:
- '9.12'
include:
- os: macos-latest
ghc: system
ghc: '9.12'
- os: windows-latest
ghc: system
ghc: '9.12'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: hspec/setup-haskell@v1
with:
ghc-version: ${{ matrix.ghc }}
- uses: sol/run-haskell-tests@v2
with:
caching: true

success:
needs: build
runs-on: ubuntu-latest
if: always() # this is required as GitHub considers "skipped" jobs as "passed" when checking branch protection rules

steps:
- run: false
if: needs.build.result != 'success'

- uses: actions/checkout@v6
- name: Check for trailing whitespace
run: '! git grep -I "\s\+$"'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Please check out the [tutorial](TUTORIAL.md).

Due to Haddock pulling the documentation directly from http-client, some "Since"
notations give the version numbers of the http-client package. For reference,
http-client-0.5.0 corresponds to http-conduit-2.2.0, and
http-client-0.5.0 corresponds to http-conduit-2.2.0, and
http-client-0.4.30 corresponds to http-conduit-2.1.11 .
2 changes: 1 addition & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The API documentation can be found at:

## Tutorial exercise

To help motivate learning, keep in mind the following exercise while reading through the tutorial,
To help motivate learning, keep in mind the following exercise while reading through the tutorial,
and try to implement a solution. Write a program that takes an
input file with one URL per line, and ensures that making a request to each URL
returns a non-error status code.
Expand Down
8 changes: 4 additions & 4 deletions http-client-tls/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ main = hspec $ do

it "make a TLS connection" $ do
manager <- newManager tlsManagerSettings
withResponse "https://httpbin.org/status/418" manager $ \res ->
withResponse "https://httpcan.org/status/418" manager $ \res ->
responseStatus res `shouldBe` status418

it "digest authentication" $ do
man <- newManager defaultManagerSettings
req <- join $ applyDigestAuth
"user"
"passwd"
"http://httpbin.org/digest-auth/qop/user/passwd"
"http://httpcan.org/digest-auth/auth/user/passwd"
man
response <- httpNoBody req man
responseStatus response `shouldBe` status200

it "incorrect digest authentication" $ do
man <- newManager defaultManagerSettings
join (applyDigestAuth "user" "passwd" "http://httpbin.org/" man)
join (applyDigestAuth "user" "passwd" "http://httpcan.org/" man)
`shouldThrow` \(DigestAuthException _ _ det) ->
det == UnexpectedStatusCode

Expand Down Expand Up @@ -82,6 +82,6 @@ main = hspec $ do

it "global supports TLS" $ do
manager <- getGlobalManager
request <- parseRequest "https://httpbin.org"
request <- parseRequest "https://httpcan.org"
response <- httpNoBody request manager
responseStatus response `shouldBe` status200
1 change: 0 additions & 1 deletion http-client/test-nonet/Network/HTTP/Client/RequestSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ spec = do
case xs of
(x:xs') -> (xs', x)
[] -> ([], "")

26 changes: 13 additions & 13 deletions http-client/test/Network/HTTP/ClientSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ main = hspec spec
spec :: Spec
spec = describe "Client" $ do
it "works" $ do
req <- parseUrlThrow "http://httpbin.org/"
req <- parseUrlThrow "http://httpcan.org/"
man <- newManager defaultManagerSettings
res <- httpLbs req man
responseStatus res `shouldBe` status200

-- Test the failure condition described in https://github.com/snoyberg/http-client/issues/489
it "keeps connection alive long enough" $ do
req <- parseUrlThrow "http://httpbin.org/"
req <- parseUrlThrow "http://httpcan.org/"
man <- newManager defaultManagerSettings
res <- responseOpen req man
responseStatus res `shouldBe` status200
Expand All @@ -51,39 +51,39 @@ spec = describe "Client" $ do

describe "method in URL" $ do
it "success" $ do
req <- parseUrlThrow "POST http://httpbin.org/post"
req <- parseUrlThrow "POST http://httpcan.org/post"
man <- newManager defaultManagerSettings
res <- httpLbs req man
responseStatus res `shouldBe` status200

it "failure" $ do
req <- parseRequest "PUT http://httpbin.org/post"
req <- parseRequest "PUT http://httpcan.org/post"
man <- newManager defaultManagerSettings
res <- httpLbs req man
responseStatus res `shouldBe` status405
describe "bearer auth" $ do
it "success" $ do
initialReq <- parseUrlThrow "http://httpbin.org/bearer"
initialReq <- parseUrlThrow "http://httpcan.org/bearer"
let finalReq = applyBearerAuth "token" initialReq
man <- newManager defaultManagerSettings
res <- httpLbs finalReq man
responseStatus res `shouldBe` status200
it "failure" $ do
req <- parseRequest "http://httpbin.org/bearer"
req <- parseRequest "http://httpcan.org/bearer"
man <- newManager defaultManagerSettings
res <- httpLbs req man
responseStatus res `shouldBe` status401

describe "redirects" $ do
xit "follows redirects" $ do
req <- parseRequest "http://httpbin.org/redirect-to?url=http://httpbin.org"
req <- parseRequest "http://httpcan.org/redirect-to?url=http://httpcan.org"
man <- newManager defaultManagerSettings
res <- httpLbs req man
responseStatus res `shouldBe` status200

xit "allows to disable redirect following" $ do
req <- (\ r -> r{ redirectCount = 0 }) <$>
parseRequest "http://httpbin.org/redirect-to?url=http://httpbin.org"
parseRequest "http://httpcan.org/redirect-to?url=http://httpcan.org"
man <- newManager defaultManagerSettings
res <- httpLbs req man
responseStatus res `shouldBe` found302
Expand All @@ -99,7 +99,7 @@ spec = describe "Client" $ do
}
settings = defaultManagerSettings { managerModifyResponse = modify }
man <- newManager settings
res <- httpLbs "http://httpbin.org" man
res <- httpLbs "http://httpcan.org" man
(statusCode.responseStatus) res `shouldBe` 201

it "modifies the response body" $ do
Expand All @@ -111,28 +111,28 @@ spec = describe "Client" $ do
}
settings = defaultManagerSettings { managerModifyResponse = modify }
man <- newManager settings
res <- httpLbs "http://httpbin.org" man
res <- httpLbs "http://httpcan.org" man
responseBody res `shouldBe` "modified response body"

context "managerModifyRequest" $ do
it "port" $ do
let modify req = return req { port = 80 }
settings = defaultManagerSettings { managerModifyRequest = modify }
man <- newManager settings
res <- httpLbs "http://httpbin.org:1234" man
res <- httpLbs "http://httpcan.org:1234" man
responseStatus res `shouldBe` status200

it "checkResponse" $ do
let modify req = return req { checkResponse = \_ _ -> error "some exception" }
settings = defaultManagerSettings { managerModifyRequest = modify }
man <- newManager settings
httpLbs "http://httpbin.org" man `shouldThrow` anyException
httpLbs "http://httpcan.org" man `shouldThrow` anyException

xit "redirectCount" $ do
let modify req = return req { redirectCount = 0 }
settings = defaultManagerSettings { managerModifyRequest = modify }
man <- newManager settings
response <- httpLbs "http://httpbin.org/redirect-to?url=foo" man
response <- httpLbs "http://httpcan.org/redirect-to?url=foo" man
responseStatus response `shouldBe` found302

-- skipped because CI doesn't have working IPv6
Expand Down
6 changes: 3 additions & 3 deletions http-conduit/http-conduit.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test-suite test
type: exitcode-stdio-1.0
hs-source-dirs: test

ghc-options: -Wall
ghc-options: -Wall -threaded
cpp-options: -DDEBUG
build-depends: base >= 4 && < 5
, HUnit
Expand All @@ -68,7 +68,7 @@ test-suite test
, warp-tls
, tls < 1.5 || >= 1.5.2
, time
, time-manager < 0.3
, time-manager
, blaze-builder
, bytestring
, text
Expand All @@ -77,7 +77,7 @@ test-suite test
, utf8-string
, case-insensitive
, unliftio
, wai >= 3.0 && < 3.3
, wai >= 3.0
, warp >= 3.0.0.2
, wai-conduit
, http-types
Expand Down
Loading