-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wip] testing chunked transfer encoding
- Loading branch information
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Test | ||
|
||
import Data.Nat | ||
import Network.HTTP | ||
import Control.Monad.Error.Either | ||
import Control.Monad.Error.Interface | ||
|
||
ResultMonad : Type -> Type | ||
ResultMonad = EitherT (HttpError ()) IO | ||
|
||
getClient: IO (HttpClient ()) | ||
getClient = new_client certificate_ignore_check 1 1 False False | ||
|
||
performRequest : HttpClient () -> ResultMonad (HttpResponse, Stream (Of Bits8) ResultMonad ()) | ||
performRequest client = | ||
request client GET (url' "https://anglesharp.azurewebsites.net/Chunked") [("Authorization", "Bearer foo")] () | ||
|
||
silly_me = do | ||
client <- getClient | ||
Right (result, stream) <- runEitherT $ performRequest client | ||
| Left e => printLn $ "Error from calling url " ++ show e | ||
putStrLn $ show result | ||
Right (content, _) <- runEitherT $ toList stream | ||
| Left e => printLn $ "Error from reading response stream " ++ show e | ||
putStrLn $ show content | ||
putStrLn "Done" | ||
close client |