Safe Haskell | None |
---|
- requestWithAuth :: String -> String -> (Request (ResourceT IO) -> IO (Response body)) -> Request (ResourceT IO) -> MaybeT IO (Response body)
- data Challenge
- realm :: Challenge -> Maybe String
- getChallenge :: Response body -> Maybe Challenge
- makeRequestHeader :: Monad m => String -> String -> String -> Request m -> Challenge -> MaybeT m String
- extractAuthHeader :: Response body -> Maybe String
- parseChallenge :: String -> Maybe Challenge
- makeRequestUri :: Request m -> String
- makeRequestBodyHash :: Monad m => Request m -> m String
Documentation
:: String | login |
-> String | password |
-> (Request (ResourceT IO) -> IO (Response body)) | function like |
-> Request (ResourceT IO) | request to send (without authorization) |
-> MaybeT IO (Response body) |
This is the main function. It sends a request, gets the response, and, if this response requires authorization, it sends the same request again, now including authorization data (user-supplied login and password).
High-level functions
This is an abstract type representing the challenge sent by the server.
realm :: Challenge -> Maybe StringSource
Realm is the only thing users are supposed to know about the challenge.
getChallenge :: Response body -> Maybe ChallengeSource
This function parses the response headers to get the challenge. It failes if there is some challenge, but it can't be parsed. If there is no challenge at all, function doesn't fail.
:: Monad m | |
=> String | login |
-> String | password |
-> String | string to use as cnonce, not very important yet |
-> Request m | first request, already sent to the server |
-> Challenge | challenge generated by server in responce to that request |
-> MaybeT m String |
This function creates a string that should be sent in the Authorization header.
Low-level functions
extractAuthHeader :: Response body -> Maybe StringSource
This function extracts a WWW-Authenticate header from the response.
parseChallenge :: String -> Maybe ChallengeSource
This function parses the WWW-Authenticate header line to get a challenge. If it fails, it's probably because the header is malformed
Utils
makeRequestUri :: Request m -> StringSource
This function extracts URI part from the request. It wouldn't include the host name.
makeRequestBodyHash :: Monad m => Request m -> m StringSource
This function makes an MD5 hash of the request body