本文整理汇总了C++中HttpHeader::find方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpHeader::find方法的具体用法?C++ HttpHeader::find怎么用?C++ HttpHeader::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHeader
的用法示例。
在下文中一共展示了HttpHeader::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
HttpOtpPostLogin::HttpOtpPostLogin(const char* buf, unsigned len, const UString& user_field,
const UString& pin_field, const UString& token_field, const UString& passwd_field,
const UString& cf_field, HttpHeader& header)
{
U_TRACE(5, "HttpOtpPostLogin::HttpOtpPostLogin(%.*S,%u,%.*S,%.*S,%.*S,%.*S,%p)", len, buf, len,
U_STRING_TO_TRACE(user_field), U_STRING_TO_TRACE(pin_field), U_STRING_TO_TRACE(token_field),
U_STRING_TO_TRACE(passwd_field), U_STRING_TO_TRACE(cf_field), &header)
HttpField* f = header.find(U_STRING_FROM_CONSTANT("Content-Type"));
U_INTERNAL_ASSERT_POINTER(f)
U_INTERNAL_ASSERT(f->value.find("application/x-www-form-urlencoded") != unsigned(-1))
buffer.assign(buf, len);
(void) U_VEC_SPLIT(vec, buffer, "=&"); // "user=stefano+casazza&pin=12345&token=autorizzativo"
unsigned i = 0;
while (i < vec.size())
{
if (vec[i] == user_field)
{
U_STR_RESERVE(user, 64);
Url::decode(vec[i+1], user);
}
else if (vec[i] == pin_field)
{
U_STR_RESERVE(pin, 64);
Url::decode(vec[i+1], pin);
}
else if (vec[i] == token_field)
{
U_STR_RESERVE(token, 64);
Url::decode(vec[i+1], token);
}
else if (vec[i] == passwd_field)
{
U_STR_RESERVE(passwd, 64);
Url::decode(vec[i+1], passwd);
}
else if (vec[i] == cf_field)
{
U_STR_RESERVE(cf, 64);
Url::decode(vec[i+1], cf);
}
i += 2;
}
}
示例2: main
int
U_EXPORT main (int argc, char* argv[])
{
U_ULIB_INIT(argv);
U_TRACE(5,"main(%d)",argc)
UString value, path, domain, port, not_found;
HttpCookie c1(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM("Name=value")),
c2(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_2)),
c5(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_5));
U_ASSERT( c5.find(U_STRING_FROM_CONSTANT("otptoken"), value, path, domain, port) == true )
U_ASSERT( value == U_STRING_FROM_CONSTANT("pluto") )
U_ASSERT( c1.count(U_STRING_FROM_CONSTANT("Name")) == 1 )
U_ASSERT( c2.count(U_STRING_FROM_CONSTANT("$Domain")) == 2 )
U_ASSERT( c1.find(U_STRING_FROM_CONSTANT("Name"), value, path, domain, port) == true )
U_ASSERT( value == U_STRING_FROM_CONSTANT("value") )
U_ASSERT( path == not_found )
U_ASSERT( domain == not_found )
U_ASSERT( port == not_found )
U_ASSERT( c2.find(U_STRING_FROM_CONSTANT("NameB"), value, path, domain, port) == true )
U_ASSERT( value == U_STRING_FROM_CONSTANT("ValueB") )
U_ASSERT( domain == U_STRING_FROM_CONSTANT("domain1") )
U_ASSERT( port == not_found )
#ifdef SERGIO
U_ASSERT( path == U_STRING_FROM_CONSTANT("/") )
#else
U_ASSERT( path == U_STRING_FROM_CONSTANT("\"/\"") )
#endif
U_ASSERT( c2.del(U_STRING_FROM_CONSTANT("NameB")) == true )
value = path = domain = port = not_found;
U_ASSERT( c2.find(U_STRING_FROM_CONSTANT("Name"), value, path, domain, port) == false )
U_ASSERT( value == not_found )
U_ASSERT( path == not_found )
U_ASSERT( domain == not_found )
U_ASSERT( port == not_found )
U_ASSERT( c2.find(U_STRING_FROM_CONSTANT("NameC"), value, path, domain, port) == true )
U_ASSERT( value == U_STRING_FROM_CONSTANT("ValueC") )
U_ASSERT( path == U_STRING_FROM_CONSTANT("domain1") )
#ifdef SERGIO
U_ASSERT( port == U_STRING_FROM_CONSTANT("123") )
U_ASSERT( domain == U_STRING_FROM_CONSTANT("/") )
#else
U_ASSERT( port == U_STRING_FROM_CONSTANT("\"123\"") )
U_ASSERT( domain == U_STRING_FROM_CONSTANT("\"/\"") )
#endif
HttpSetCookie s1(U_CONSTANT_TO_PARAM("Set-Cookie"), U_CONSTANT_TO_PARAM(SETCOOKIE_1)),
s2(U_CONSTANT_TO_PARAM("Set-Cookie2"), U_CONSTANT_TO_PARAM(SETCOOKIE_2));
U_ASSERT( s1.count(U_STRING_FROM_CONSTANT("Domain")) == 2 )
U_ASSERT( s2.count(U_STRING_FROM_CONSTANT("Port")) == 1 )
HttpCookie c3(U_CONSTANT_TO_PARAM("Cookie"), U_CONSTANT_TO_PARAM(COOKIE_AUTH) );
U_ASSERT( c3.count(U_STRING_FROM_CONSTANT("AUTHTOKEN")) == 1 )
value = path = domain = port = not_found;
U_ASSERT( c3.find(U_STRING_FROM_CONSTANT("AUTHTOKEN"), value, path, domain, port) == true )
U_ASSERT( path == not_found )
U_ASSERT( domain == not_found )
U_ASSERT( port == not_found )
value.erase(value.size()-1, 1);
value.erase(0, 1);
#ifdef U_PROXY_UNIT
DES3engine eng("pippo");
OtpAuthToken a(&eng, value);
#else
u_des3_key("pippo");
OtpAuthToken a(0, value);
#endif
U_ASSERT( a.tid == U_STRING_FROM_CONSTANT("Current_Server_ID") )
U_ASSERT( a.uid == U_STRING_FROM_CONSTANT("User_ID") )
U_ASSERT( a.sid == U_STRING_FROM_CONSTANT("Session_ID") )
U_ASSERT( a.ts == U_STRING_FROM_CONSTANT("20031125131800") )
U_ASSERT( a.cf == U_STRING_FROM_CONSTANT("codicefiscale1") )
U_ASSERT( a.migrate == true )
HttpHeader h;
HttpField* f = new HttpField(U_STRING_FROM_CONSTANT("Content-Type"), U_STRING_FROM_CONSTANT(" application/x-www-form-urlencoded"));
HttpBaAuthorization* ba = new HttpBaAuthorization(U_CONSTANT_TO_PARAM("Authorization"),
U_CONSTANT_TO_PARAM(" Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="));
HttpBaAuthorization* ba1 = new HttpBaAuthorization(U_CONSTANT_TO_PARAM("Authorization"),
U_CONSTANT_TO_PARAM(" Basic dXRlbnRlMTpzaWQx"));
//.........这里部分代码省略.........