/mordor/http/basic.cpp

http://github.com/mozy/mordor · C++ · 27 lines · 19 code · 7 blank · 1 comment · 0 complexity · 065ec957e0eb875054f9dd2daa745738 MD5 · raw file

  1. // Copyright (c) 2009 - Mozy, Inc.
  2. #include "basic.h"
  3. #include "http.h"
  4. #include "mordor/string.h"
  5. namespace Mordor {
  6. namespace HTTP {
  7. namespace BasicAuth {
  8. void authorize(AuthParams &authorization, const std::string &username,
  9. const std::string &password)
  10. {
  11. authorization.scheme = "Basic";
  12. authorization.param = base64encode(username + ":" + password);
  13. authorization.parameters.clear();
  14. }
  15. void authorize(Request &nextRequest,
  16. const std::string &username, const std::string &password,
  17. bool proxy)
  18. { authorize(proxy ? nextRequest.request.proxyAuthorization :
  19. nextRequest.request.authorization, username, password); }
  20. }}}