本文整理汇总了C++中HTTPResponse::set方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPResponse::set方法的具体用法?C++ HTTPResponse::set怎么用?C++ HTTPResponse::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testAuthenticationParams
void HTTPCredentialsTest::testAuthenticationParams()
{
const std::string authInfo("nonce=\"212573bb90170538efad012978ab811f%lu\", realm=\"TestDigest\", response=\"40e4889cfbd0e561f71e3107a2863bc4\", uri=\"/digest/\", username=\"user\"");
HTTPAuthenticationParams params(authInfo);
assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
assert (params["realm"] == "TestDigest");
assert (params["response"] == "40e4889cfbd0e561f71e3107a2863bc4");
assert (params["uri"] == "/digest/");
assert (params["username"] == "user");
assert (params.size() == 5);
assert (params.toString() == authInfo);
params.clear();
HTTPRequest request;
request.set("Authorization", "Digest " + authInfo);
params.fromRequest(request);
assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
assert (params["realm"] == "TestDigest");
assert (params["response"] == "40e4889cfbd0e561f71e3107a2863bc4");
assert (params["uri"] == "/digest/");
assert (params["username"] == "user");
assert (params.size() == 5);
params.clear();
HTTPResponse response;
response.set("WWW-Authenticate", "Digest realm=\"TestDigest\", nonce=\"212573bb90170538efad012978ab811f%lu\"");
params.fromResponse(response);
assert (params["realm"] == "TestDigest");
assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
assert (params.size() == 2);
}
示例2: testProxyCredentialsDigest
void HTTPCredentialsTest::testProxyCredentialsDigest()
{
HTTPCredentials creds("user", "s3cr3t");
HTTPRequest request(HTTPRequest::HTTP_GET, "/digest/");
HTTPResponse response;
response.set("Proxy-Authenticate", "Digest realm=\"TestDigest\", nonce=\"212573bb90170538efad012978ab811f%lu\"");
creds.proxyAuthenticate(request, response);
assert (request.get("Proxy-Authorization") == "Digest username=\"user\", nonce=\"212573bb90170538efad012978ab811f%lu\", realm=\"TestDigest\", uri=\"/digest/\", response=\"40e4889cfbd0e561f71e3107a2863bc4\"");
}
示例3: testProxyCredentialsBasic
void HTTPCredentialsTest::testProxyCredentialsBasic()
{
HTTPCredentials creds("user", "s3cr3t");
HTTPRequest request(HTTPRequest::HTTP_GET, "/basic/");
HTTPResponse response;
response.set("Proxy-Authenticate", "Basic realm=\"TestBasic\"");
creds.proxyAuthenticate(request, response);
assert (request.get("Proxy-Authorization") == "Basic dXNlcjpzM2NyM3Q=");
}
示例4: testVerifyAuthInfoQoP
void HTTPCredentialsTest::testVerifyAuthInfoQoP()
{
HTTPDigestCredentials creds("user", "s3cr3t");
HTTPRequest request(HTTPRequest::HTTP_GET, "/digest/");
HTTPResponse response;
response.set("WWW-Authenticate", "Digest realm=\"TestDigest\", nonce=\"212573bb90170538efad012978ab811f%lu\", opaque=\"opaque\", qop=\"auth,auth-int\"");
creds.authenticate(request, response);
assert (creds.verifyAuthInfo(request));
request.set("Authorization", "Digest cnonce=\"f9c80ffd1c3bc4ee47ed92b704ba75a4\", nc=00000001, nonce=\"212573bb90170538efad012978ab811f%lu\", opaque=\"opaque\", qop=\"auth\", realm=\"TestDigest\", response=\"ff0e90b9aa019120ea0ed6e23ce95d9a\", uri=\"/digest/\", username=\"user\"");
assert (!creds.verifyAuthInfo(request));
}
示例5: testVerifyAuthInfo
void HTTPCredentialsTest::testVerifyAuthInfo()
{
HTTPDigestCredentials creds("user", "s3cr3t");
HTTPRequest request(HTTPRequest::HTTP_GET, "/digest/");
HTTPResponse response;
response.set("WWW-Authenticate", "Digest realm=\"TestDigest\", nonce=\"212573bb90170538efad012978ab811f%lu\"");
creds.authenticate(request, response);
assert (creds.verifyAuthInfo(request));
request.set("Authorization", "Digest nonce=\"212573bb90170538efad012978ab811f%lu\", realm=\"TestDigest\", response=\"xxe4889cfbd0e561f71e3107a2863bc4\", uri=\"/digest/\", username=\"user\"");
assert (!creds.verifyAuthInfo(request));
}
示例6: testDigestCredentialsQoP
void HTTPCredentialsTest::testDigestCredentialsQoP()
{
HTTPDigestCredentials creds("user", "s3cr3t");
HTTPRequest request(HTTPRequest::HTTP_GET, "/digest/");
HTTPResponse response;
response.set("WWW-Authenticate", "Digest realm=\"TestDigest\", nonce=\"212573bb90170538efad012978ab811f%lu\", opaque=\"opaque\", qop=\"auth,auth-int\"");
creds.authenticate(request, response);
HTTPAuthenticationParams params(request);
assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
assert (params["realm"] == "TestDigest");
assert (params["response"] != "40e4889cfbd0e561f71e3107a2863bc4");
assert (params["uri"] == "/digest/");
assert (params["username"] == "user");
assert (params["opaque"] == "opaque");
assert (params["cnonce"] != "");
assert (params["nc"] == "00000001");
assert (params["qop"] == "auth");
assert (params.size() == 9);
std::string cnonce = params["cnonce"];
std::string aresp = params["response"];
params.clear();
creds.updateAuthInfo(request);
params.fromRequest(request);
assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
assert (params["realm"] == "TestDigest");
assert (params["response"] != aresp);
assert (params["uri"] == "/digest/");
assert (params["username"] == "user");
assert (params["opaque"] == "opaque");
assert (params["cnonce"] == cnonce);
assert (params["nc"] == "00000002");
assert (params["qop"] == "auth");
assert (params.size() == 9);
}