本文整理汇总了C++中NameValuePair::data方法的典型用法代码示例。如果您正苦于以下问题:C++ NameValuePair::data方法的具体用法?C++ NameValuePair::data怎么用?C++ NameValuePair::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameValuePair
的用法示例。
在下文中一共展示了NameValuePair::data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iterator
// Construct a MimeBodyPart from an HttpBody and a list of parameters.
MimeBodyPart::MimeBodyPart(const HttpBody& httpBody,
//< Provides the bytes of the body.
const UtlDList& parameters
//< Provides the parameters.
) :
HttpBody(httpBody),
mpParentBody(NULL),
mParentBodyRawStartIndex(-1),
mRawBodyLength(-1),
mParentBodyStartIndex(-1),
mBodyLength(-1)
{
// Copy the parameters to mNameValues.
UtlDListIterator iterator(parameters);
NameValuePair* nvp;
while((nvp = (NameValuePair*) iterator()))
{
mNameValues.append(new NameValuePair(nvp->data(), nvp->getValue()));
}
// Add the Content-Type parameter, taken from the HttpBody.
mNameValues.append(new NameValuePair(HTTP_CONTENT_TYPE_FIELD,
httpBody.getContentType()));
// Add the Content-Transfer-Encoding parameter.
mNameValues.append(new NameValuePair(HTTP_CONTENT_TRANSFER_ENCODING_FIELD,
HTTP_CONTENT_TRANSFER_ENCODING_BINARY));
// Members that reference the parent will be corrected later.
}
示例2: parseCgiVariables
//.........这里部分代码省略.........
int lastCharIndex = 0;
int relativeIndex;
int nameValueRelativeIndex;
int queryStringLength = strlen(queryString);
do
{
// Pull out a name value pair
//osPrintf("HttpRequestContext::parseCgiVariables parseCgiVariables: \"%s\" lastCharIndex: %d",
// &(queryString[lastCharIndex]), lastCharIndex);
NameValueTokenizer::getSubField(&(queryString[lastCharIndex]),
queryStringLength - lastCharIndex,
0,
pairSeparator,
nameAndValuePtr,
nameAndValueLength,
&relativeIndex);
lastCharIndex += relativeIndex;
if(nameAndValuePtr && nameAndValueLength > 0)
{
// Separate the name and value
NameValueTokenizer::getSubField(nameAndValuePtr,
nameAndValueLength,
0,
nameValueSeparator,
namePtr,
nameLength,
&nameValueRelativeIndex);
// Get rid of leading white space in the name
while(nameLength > 0 &&
(*namePtr == ' ' ||
*namePtr == '\t'))
{
nameLength--;
namePtr++;
}
if(nameLength > 0)
{
// Ignore any subsequent name value separators should they exist
//int nvSeparatorIndex = nameAndValue.index(nameValueSeparator);
int valueSeparatorOffset = strspn(&(namePtr[nameLength]),
nameValueSeparator);
const char* valuePtr = &(namePtr[nameLength]) + valueSeparatorOffset;
int valueLength = nameAndValueLength -
(valuePtr - nameAndValuePtr);
// If there is a value
if(valueSeparatorOffset <= 0 ||
*valuePtr == '\0' ||
valueLength <= 0)
{
valuePtr = NULL;
valueLength = 0;
}
// Construct the new pair of the right subclass of NameValuePair
// to have the compareTo method we want.
NameValuePair* newNvPair =
nameIsCaseInsensitive ?
new NameValuePairInsensitive("") :
new NameValuePair("");
newNvPair->append(namePtr, nameLength);
if(valuePtr)
{
value.remove(0);
value.append(valuePtr, valueLength);
NameValueTokenizer::frontBackTrim(&value, " \t\n\r");
unescape(value);
newNvPair->setValue(value);
}
else
{
newNvPair->setValue("");
}
// Unescape the name.
unescape(*newNvPair);
NameValueTokenizer::frontBackTrim(newNvPair, " \t\n\r");
# ifdef TEST_DEBUG
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"HttpRequestContext::parseCgiVariables adding %p '%s' -> '%s'",
&cgiVariableList, newNvPair->data(), newNvPair->getValue()
);
# endif
// Add the name, value pair to the list
cgiVariableList.insert(newNvPair);
nameValueIndex++;
}
}
} while(nameAndValuePtr &&
nameAndValueLength > 0 &&
queryString[lastCharIndex] != '\0');
}
示例3: getCgiVariable
UtlBoolean HttpRequestContext::getCgiVariable(const char* name,
UtlString& value,
int occurance) const
{
UtlSListIterator iterator((UtlSList&)mCgiVariableList);
NameValuePair* nameValuePair = NULL;
int fieldIndex = 0;
UtlString upperCaseName;
UtlBoolean foundName = FALSE;
value.remove(0);
# ifdef TEST_DEBUG
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"HttpRequestContext::getCgiVariable %p (\"%s\",<val>,%d)",
&mCgiVariableList, name, occurance
);
# endif
if(name)
{
upperCaseName.append(name);
upperCaseName.toUpper();
}
NameValuePair *matchName = ( mUsingInsensitive
? new NameValuePair(upperCaseName)
: new NameValuePairInsensitive(upperCaseName)
);
// For each name value:
for (fieldIndex = 0, nameValuePair = (NameValuePair*) iterator.findNext(matchName);
fieldIndex < occurance;
fieldIndex++
)
{
nameValuePair = (NameValuePair*) iterator.findNext(matchName);
# ifdef TEST_DEBUG
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"HttpRequestContext::getCgiVariable(name,val,occ) %p skipping %d '%s' -> '%s'",
&mCgiVariableList,
fieldIndex,
nameValuePair ? nameValuePair->data() : "UNFOUND",
nameValuePair ? nameValuePair->getValue() : "UNFOUND"
);
# endif
}
delete matchName;
# ifdef TEST_DEBUG
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"HttpRequestContext::getCgiVariable(name,val,occ) %p stopped at %d '%s' -> '%s'",
&mCgiVariableList, fieldIndex,
nameValuePair ? nameValuePair->data() : "UNFOUND",
nameValuePair ? nameValuePair->getValue() : "UNFOUND"
);
# endif
if(fieldIndex == occurance && nameValuePair)
{
value.append(nameValuePair->getValue());
foundName = TRUE;
}
return(foundName);
}
示例4: appendBodyPart
// Append a multipart body part to an existing multiparty body.
void HttpBody::appendBodyPart(const HttpBody& body,
const UtlDList& parameters)
{
assert(isMultipart());
// Construct a new MimeBodyPart for the new body part.
MimeBodyPart* part = new MimeBodyPart(body, parameters);
// Insert it as the last body part.
mBodyParts.append(part);
mBodyPartCount++;
// Turn the final boundary into an intermediate boundary.
mBody.remove(mBody.length() - 4);
mBody.append("\r\n");
// Insert the headers.
ssize_t rawPartStart = mBody.length();
UtlDListIterator iterator(*part->getParameters());
NameValuePair* nvp;
while ((nvp = (NameValuePair*) iterator()))
{
mBody.append(nvp->data());
mBody.append(": ");
mBody.append(nvp->getValue());
mBody.append("\r\n");
}
mBody.append("\r\n");
// Insert the body.
ssize_t partStart = mBody.length();
const char* bytes;
ssize_t length;
body.getBytes(&bytes, &length);
mBody.append(bytes, length);
ssize_t partEnd = mBody.length();
// Update bodyLength.
bodyLength = mBody.length();
// Determine if we have to change the boundary string.
bool change_boundary_string =
mBody.index(mMultipartBoundary, partStart) != UTL_NOT_FOUND;
// Add the final boundary.
mBody.append("\r\n--");
mBody.append(mMultipartBoundary);
mBody.append("--\r\n");
// Update the MimeBodyPart to know where it is contained in the HttpBody.
part->attach(this,
rawPartStart, partEnd - rawPartStart,
partStart, partEnd - partStart);
// If we have to change the boundary string.
if (change_boundary_string)
{
// Find a new boundary string that isn't in the body.
do {
nextBoundary(mMultipartBoundary);
} while (mBody.index(mMultipartBoundary) != UTL_NOT_FOUND);
// Replace the old boundary string.
UtlSListIterator iterator(mBodyParts);
MimeBodyPart* part;
while ((part = dynamic_cast<MimeBodyPart*>(iterator())))
{
// Replace the boundary string just before this part.
mBody.replace(part->getRawStart() - (2 + BOUNDARY_STRING_LENGTH),
BOUNDARY_STRING_LENGTH,
mMultipartBoundary.data(),
BOUNDARY_STRING_LENGTH);
}
// Replace the boundary string in the final boundary.
mBody.replace(mBody.length() - (4 + BOUNDARY_STRING_LENGTH),
BOUNDARY_STRING_LENGTH,
mMultipartBoundary.data(),
BOUNDARY_STRING_LENGTH);
// Replace the boundary string in the Content-Type.
ssize_t loc = this->index(";" MULTIPART_BOUNDARY_PARAMETER "=\"");
this->replace(loc + sizeof (";" MULTIPART_BOUNDARY_PARAMETER "=\"") - 1,
BOUNDARY_STRING_LENGTH,
mMultipartBoundary.data(),
BOUNDARY_STRING_LENGTH);
}
}