@@ -33,25 +33,25 @@ spec :: Spec
3333spec = do
3434 describe "exception throwing on non-2xx status codes" $
3535 it "throws indeed for non-2xx" $
36− req GET (httpbin /: "foo") NoReqBody ignoreResponse mempty
36+ req GET (httpbun /: "foo") NoReqBody ignoreResponse mempty
3737 `shouldThrow` selector404
3838
3939 describe "exception throwing on non-2xx status codes (Req monad)" $
4040 it "throws indeed for non-2xx" $
4141 asIO . runReq defaultHttpConfig $
4242 liftBaseWith $ \run ->
43− run (req GET (httpbin /: "foo") NoReqBody ignoreResponse mempty)
43+ run (req GET (httpbun /: "foo") NoReqBody ignoreResponse mempty)
4444 `shouldThrow` selector404
4545
4646 describe "response check via httpConfigCheckResponse" $
4747 context "if it's set to always throw" $
4848 it "throws indeed" $
49− blindlyThrowing (req GET httpbin NoReqBody ignoreResponse mempty)
49+ blindlyThrowing (req GET httpbun NoReqBody ignoreResponse mempty)
5050 `shouldThrow` anyException
5151
5252 describe "isStatusCodeException" $
5353 it "extracts non-2xx response" $
54− req GET (httpbin /: "foo") NoReqBody ignoreResponse mempty
54+ req GET (httpbun /: "foo") NoReqBody ignoreResponse mempty
5555 `shouldThrow` selector404ByStatusCodeException
5656
5757 describe "receiving user-agent header back" $
@@ -59,7 +59,7 @@ spec = do
5959 r <-
6060 req
6161 GET
62− (httpbin /: "user-agent")
62+ (httpbun /: "user-agent")
6363 NoReqBody
6464 jsonResponse
6565 (header "user-agent" "Req")
@@ -74,7 +74,7 @@ spec = do
7474 r <-
7575 req
7676 GET
77− (httpbin /: "headers")
77+ (httpbun /: "headers")
7878 NoReqBody
7979 jsonResponse
8080 (header "Foo" "bar" <> header "Baz" "quux")
@@ -84,8 +84,7 @@ spec = do
8484 .= object
8585 [ "Accept-Encoding" .= ("gzip" :: Text),
8686 "Foo" .= ("bar" :: Text),
87− "Baz" .= ("quux" :: Text),
88− "Host" .= ("httpbin.org" :: Text)
87+ "Baz" .= ("quux" :: Text)
8988 ]
9089 ]
9190 responseStatusCode r `shouldBe` 200
@@ -93,15 +92,15 @@ spec = do
9392
9493 describe "receiving GET data back" $
9594 it "works" $ do
96− r <- req GET (httpbin /: "get") NoReqBody jsonResponse mempty
95+ r <- req GET (httpbun /: "get") NoReqBody jsonResponse mempty
9796 (stripFunnyHeaders . stripOrigin) (responseBody r)
9897 `shouldBe` object
9998 [ "args" .= emptyObject,
100− "url" .= ("https://httpbin.org/get" :: Text),
99+ "url" .= ("https://httpbun.org/get" :: Text),
100+ "method" .= ("GET" :: Text),
101101 "headers"
102102 .= object
103− [ "Accept-Encoding" .= ("gzip" :: Text),
104− "Host" .= ("httpbin.org" :: Text)
103+ [ "Accept-Encoding" .= ("gzip" :: Text)
105104 ]
106105 ]
107106 responseHeader r "Content-Type" `shouldBe` return "application/json"
@@ -112,18 +111,18 @@ spec = do
112111 it "works" $ do
113112 let text = "foo" :: Text
114113 reflected = reflectJSON text
115− r <- req POST (httpbin /: "post") (ReqBodyJson text) jsonResponse mempty
114+ r <- req POST (httpbun /: "post") (ReqBodyJson text) jsonResponse mempty
116115 (stripFunnyHeaders . stripOrigin) (responseBody r)
117116 `shouldBe` object
118117 [ "args" .= emptyObject,
119118 "json" .= text,
120119 "data" .= reflected,
121− "url" .= ("https://httpbin.org/post" :: Text),
120+ "url" .= ("https://httpbun.org/post" :: Text),
121+ "method" .= ("POST" :: Text),
122122 "headers"
123123 .= object
124124 [ "Content-Type" .= ("application/json; charset=utf-8" :: Text),
125125 "Accept-Encoding" .= ("gzip" :: Text),
126− "Host" .= ("httpbin.org" :: Text),
127126 "Content-Length" .= show (T.length reflected)
128127 ],
129128 "files" .= emptyObject,
@@ -140,19 +139,19 @@ spec = do
140139 [ LM.partBS "foo" "foo data!",
141140 LM.partBS "bar" "bar data!"
142141 ]
143− r <- req POST (httpbin /: "post") body jsonResponse mempty
142+ r <- req POST (httpbun /: "post") body jsonResponse mempty
144143 let contentType = fromJust (getRequestContentType body)
145144 (stripFunnyHeaders . stripOrigin) (responseBody r)
146145 `shouldBe` object
147146 [ "args" .= emptyObject,
148147 "json" .= Null,
149148 "data" .= ("" :: Text),
150− "url" .= ("https://httpbin.org/post" :: Text),
149+ "url" .= ("https://httpbun.org/post" :: Text),
150+ "method" .= ("POST" :: Text),
151151 "headers"
152152 .= object
153153 [ "Content-Type" .= T.decodeUtf8 contentType,
154154 "Accept-Encoding" .= ("gzip" :: Text),
155− "Host" .= ("httpbin.org" :: Text),
156155 "Content-Length" .= ("242" :: Text)
157156 ],
158157 "files" .= emptyObject,
@@ -169,19 +168,19 @@ spec = do
169168 describe "receiving PATCHed file back" $
170169 it "works" $ do
171170 let file :: FilePath
172− file = "httpbin-data/robots.txt"
171+ file = "httpbun-data/robots.txt"
173172 contents <- TIO.readFile file
174− r <- req PATCH (httpbin /: "patch") (ReqBodyFile file) jsonResponse mempty
173+ r <- req PATCH (httpbun /: "patch") (ReqBodyFile file) jsonResponse mempty
175174 (stripFunnyHeaders . stripOrigin) (responseBody r)
176175 `shouldBe` object
177176 [ "args" .= emptyObject,
178177 "json" .= Null,
179178 "data" .= contents,
180− "url" .= ("https://httpbin.org/patch" :: Text),
179+ "url" .= ("https://httpbun.org/patch" :: Text),
180+ "method" .= ("PATCH" :: Text),
181181 "headers"
182182 .= object
183183 [ "Accept-Encoding" .= ("gzip" :: Text),
184− "Host" .= ("httpbin.org" :: Text),
185184 "Content-Length" .= show (T.length contents)
186185 ],
187186 "files" .= emptyObject,
@@ -197,18 +196,18 @@ spec = do
197196 "foo" =: ("bar" :: Text)
198197 <> "baz" =: (5 :: Int)
199198 <> queryFlag "quux"
200− r <- req PUT (httpbin /: "put") (ReqBodyUrlEnc params) jsonResponse mempty
199+ r <- req PUT (httpbun /: "put") (ReqBodyUrlEnc params) jsonResponse mempty
201200 (stripFunnyHeaders . stripOrigin) (responseBody r)
202201 `shouldBe` object
203202 [ "args" .= emptyObject,
204203 "json" .= Null,
205204 "data" .= ("" :: Text),
206− "url" .= ("https://httpbin.org/put" :: Text),
205+ "url" .= ("https://httpbun.org/put" :: Text),
206+ "method" .= ("PUT" :: Text),
207207 "headers"
208208 .= object
209209 [ "Content-Type" .= ("application/x-www-form-urlencoded" :: Text),
210210 "Accept-Encoding" .= ("gzip" :: Text),
211− "Host" .= ("httpbin.org" :: Text),
212211 "Content-Length" .= ("18" :: Text)
213212 ],
214213 "files" .= emptyObject,
@@ -223,24 +222,19 @@ spec = do
223222 responseStatusCode r `shouldBe` 200
224223 responseStatusMessage r `shouldBe` "OK"
225224
226− -- TODO /delete
227−
228− describe "receiving UTF-8 encoded Unicode data" $
229− it "works" $ do
230− r <-
231− req
232− GET
233− (httpbin /: "encoding" /: "utf8")
234− NoReqBody
235− bsResponse
236− mempty
237− utf8data <- B.readFile "httpbin-data/utf8.html"
238− responseBody r `shouldBe` utf8data
239− responseStatusCode r `shouldBe` 200
240− responseStatusMessage r `shouldBe` "OK"
241−
242− -- TODO /gzip
243− -- TODO /deflate
225+ -- describe "receiving UTF-8 encoded Unicode data" $
226+ -- it "works" $ do
227+ -- r <-
228+ -- req
229+ -- GET
230+ -- (httpbun /: "encoding" /: "utf8")
231+ -- NoReqBody
232+ -- bsResponse
233+ -- mempty
234+ -- utf8data <- B.readFile "httpbun-data/utf8.html"
235+ -- responseBody r `shouldBe` utf8data
236+ -- responseStatusCode r `shouldBe` 200
237+ -- responseStatusMessage r `shouldBe` "OK"
244238
245239 describe "retrying" $
246240 it "retries as many times as specified" $ do
@@ -251,7 +245,7 @@ spec = do
251245 prepareForShit $
252246 req
253247 GET
254− (httpbin /: "status" /~ status)
248+ (httpbun /: "status" /~ status)
255249 NoReqBody
256250 ignoreResponse
257251 mempty
@@ -263,25 +257,18 @@ spec = do
263257 forM_ [400 .. 431] checkStatusCode
264258 forM_ [500 .. 511] checkStatusCode
265259
266− -- TODO /response-headers
267− -- TODO /redirect
268−
269260 describe "redirects" $
270261 it "follows redirects" $ do
271262 r <-
272263 req
273264 GET
274− (httpbin /: "redirect-to")
265+ (httpbun /: "redirect-to")
275266 NoReqBody
276267 ignoreResponse
277− ("url" =: ("https://httpbin.org" :: Text))
268+ ("url" =: ("https://httpbun.org" :: Text))
278269 responseStatusCode r `shouldBe` 200
279270 responseStatusMessage r `shouldBe` "OK"
280271
281− -- TODO /relative-redicet
282− -- TODO /absolute-redirect
283− -- TODO /cookies
284−
285272 describe "basicAuth" $ do
286273 let user, password :: Text
287274 user = "Scooby"
@@ -292,43 +279,32 @@ spec = do
292279 prepareForShit $
293280 req
294281 GET
295− (httpbin /: "basic-auth" /~ user /~ password)
282+ (httpbun /: "basic-auth" /~ user /~ password)
296283 NoReqBody
297284 ignoreResponse
298285 mempty
299286 responseStatusCode r `shouldBe` 401
300− responseStatusMessage r `shouldBe` "UNAUTHORIZED"
287+ responseStatusMessage r `shouldBe` "Unauthorized"
301288 context "when we provide appropriate basic auth data" $
302289 it "succeeds" $ do
303290 r <-
304291 req
305292 GET
306− (httpbin /: "basic-auth" /~ user /~ password)
293+ (httpbun /: "basic-auth" /~ user /~ password)
307294 NoReqBody
308295 ignoreResponse
309296 (basicAuth (T.encodeUtf8 user) (T.encodeUtf8 password))
310297 responseStatusCode r `shouldBe` 200
311298 responseStatusMessage r `shouldBe` "OK"
312299
313− -- TODO /hidden-basic-auth
314− -- TODO /digest-auth
315− -- TODO /stream
316− -- TODO /delay
317− -- TODO /drip
318− -- TODO /range
319− -- TODO /html
320−
321300 describe "robots.txt" $
322301 it "works" $ do
323− r <- req GET (httpbin /: "robots.txt") NoReqBody bsResponse mempty
324− robots <- B.readFile "httpbin-data/robots.txt"
302+ r <- req GET (httpbun /: "robots.txt") NoReqBody bsResponse mempty
303+ robots <- B.readFile "httpbun-data/robots.txt"
325304 responseBody r `shouldBe` robots
326305 responseStatusCode r `shouldBe` 200
327306 responseStatusMessage r `shouldBe` "OK"
328307
329− -- TODO /deny
330− -- TODO /cache
331−
332308 describe "getting random bytes" $ do
333309 it "works" $
334310 property $ \n' -> do
@@ -337,7 +313,7 @@ spec = do
337313 r <-
338314 req
339315 GET
340− (httpbin /: "bytes" /~ n)
316+ (httpbun /: "bytes" /~ n)
341317 NoReqBody
342318 lbsResponse
343319 mempty
@@ -353,36 +329,27 @@ spec = do
353329 n = 1000
354330 req
355331 GET
356− (httpbin /: "bytes" /~ n)
332+ (httpbun /: "bytes" /~ n)
357333 NoReqBody
358334 (Proxy :: Proxy (JsonResponse Value))
359335 mempty
360336 `shouldThrow` selector
361337
362− describe "streaming random bytes" $
363− it "works" $
364− property $ \n' -> do
365− let n :: Word
366− n = getSmall n'
367− r <-
368− req
369− GET
370− (httpbin /: "stream-bytes" /~ n)
371− NoReqBody
372− bsResponse
373− mempty
374− responseBody r `shouldSatisfy` ((== n) . fromIntegral . B.length)
375− responseStatusCode r `shouldBe` 200
376− responseStatusMessage r `shouldBe` "OK"
377−
378−-- TODO /links
379−-- TODO /image
380−-- TODO /image/png
381−-- TODO /image/jpeg
382−-- TODO /image/webp
383−-- TODO /image/svg
384−-- TODO /forms/post
385−-- TODO /xml
338+-- describe "streaming random bytes" $
339+-- it "works" $
340+-- property $ \n' -> do
341+-- let n :: Word
342+-- n = getSmall n'
343+-- r <-
344+-- req
345+-- GET
346+-- (httpbun /: "stream-bytes" /~ n)
347+-- NoReqBody
348+-- bsResponse
349+-- mempty
350+-- responseBody r `shouldSatisfy` ((== n) . fromIntegral . B.length)
351+-- responseStatusCode r `shouldBe` 200
352+-- responseStatusMessage r `shouldBe` "OK"
386353
387354----------------------------------------------------------------------------
388355-- Instances
@@ -405,9 +372,9 @@ blindlyThrowing = runReq defaultHttpConfig {httpConfigCheckResponse = doit}
405372 where
406373 doit _ _ = error "Oops!"
407374
408−-- | 'Url' representing <https://httpbin.org>.
409−httpbin :: Url 'Https
410−httpbin = https "httpbin.org"
375+-- | 'Url' representing <https://httpbun.org>.
376+httpbun :: Url 'Https
377+httpbun = https "httpbun.org"
411378
412379-- | Remove “origin” field from JSON value. Origin may change, we don't want
413380-- to depend on that.
@@ -431,7 +398,7 @@ stripFunnyHeaders (Object m) =
431398 in Object (runIdentity (Aeson.KeyMap.alterF (pure . fmap f) "headers" m))
432399stripFunnyHeaders value = value
433400
434−-- | This is a complete test case that makes use of <https://httpbin.org> to
401+-- | This is a complete test case that makes use of <https://httpbun.org> to
435402-- get various response status codes.
436403checkStatusCode :: Int -> SpecWith ()
437404checkStatusCode code =
@@ -441,7 +408,7 @@ checkStatusCode code =
441408 prepareForShit $
442409 req
443410 GET
444− (httpbin /: "status" /~ code)
411+ (httpbun /: "status" /~ code)
445412 NoReqBody
446413 ignoreResponse
447414 mempty