PageRenderTime 266ms CodeModel.GetById 141ms app.highlight 11ms RepoModel.GetById 110ms app.codeStats 0ms

/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
 3#include "basic.h"
 4
 5#include "http.h"
 6#include "mordor/string.h"
 7
 8namespace Mordor {
 9namespace HTTP {
10namespace BasicAuth {
11
12void authorize(AuthParams &authorization, const std::string &username,
13    const std::string &password)
14{
15    authorization.scheme = "Basic";
16    authorization.param = base64encode(username + ":" + password);
17    authorization.parameters.clear();
18}
19
20void authorize(Request &nextRequest,
21    const std::string &username, const std::string &password,
22    bool proxy)
23{ authorize(proxy ? nextRequest.request.proxyAuthorization :
24    nextRequest.request.authorization, username, password); }
25
26
27}}}