Created
September 9, 2013 20:14
-
-
Save ktakashi/6500888 to your computer and use it in GitHub Desktop.
401 authentication things
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
(import (rfc http) (rfc base64)) | |
(define (auth-handler hdrs) | |
(print hdrs) | |
(let ((msg "hoge:fuga")) | |
;; need to return a list of header and value | |
`(("authorization" ,(format "Basic ~a" | |
(utf8->string | |
(base64-encode (string->utf8 msg)))))))) | |
(let-values (((code hdr body) | |
(http-get "localhost" | |
"/secret.html" | |
;; handler type | |
:auth-handler auth-handler | |
;; passing user password style | |
;; this will dispatch the authentiction method | |
;; according to the response header | |
;; :auth-user "hoge" :auth-password "fuga" | |
))) | |
(print body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment