Safe Haskell | None |
---|---|
Language | Haskell98 |
- requestWithAuth :: String -> String -> (Request -> IO (Response body)) -> Request -> MaybeT IO (Response body)
- data Challenge
- realm :: Challenge -> Maybe String
- getChallenge :: Response body -> Maybe Challenge
- makeRequestHeader :: String -> String -> String -> Request -> Challenge -> MaybeT (ResourceT IO) String
- extractAuthHeader :: Response body -> Maybe String
- parseChallenge :: String -> Maybe Challenge
- makeRequestUri :: Request -> String
- makeRequestBodyHash :: Request -> IO String
Documentation
:: String | login |
-> String | password |
-> (Request -> IO (Response body)) | function like |
-> Request | 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 String Source
Realm is the only thing users are supposed to know about the challenge.
getChallenge :: Response body -> Maybe Challenge Source
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.
:: String | login |
-> String | password |
-> String | string to use as cnonce, not very important yet |
-> Request | first request, already sent to the server |
-> Challenge | challenge generated by server in responce to that request |
-> MaybeT (ResourceT IO) String |
This function creates a string that should be sent in the Authorization header.
Low-level functions
extractAuthHeader :: Response body -> Maybe String Source
This function extracts a WWW-Authenticate header from the response.
parseChallenge :: String -> Maybe Challenge Source
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 -> String Source
This function extracts URI part from the request. It wouldn't include the host name.
makeRequestBodyHash :: Request -> IO String Source
This function makes an MD5 hash of the request body