Skip to content

Instantly share code, notes, and snippets.

@ktakashi
Created September 9, 2013 20:14
Show Gist options
  • Save ktakashi/6500888 to your computer and use it in GitHub Desktop.
Save ktakashi/6500888 to your computer and use it in GitHub Desktop.
401 authentication things
(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