本文整理汇总了C++中HTTPHeaderMap::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPHeaderMap::remove方法的具体用法?C++ HTTPHeaderMap::remove怎么用?C++ HTTPHeaderMap::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPHeaderMap
的用法示例。
在下文中一共展示了HTTPHeaderMap::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handlePost
NPError PluginView::handlePost(const char* url, const char* target, uint32 len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders)
{
if (!url || !len || !buf)
return NPERR_INVALID_PARAM;
FrameLoadRequest frameLoadRequest;
HTTPHeaderMap headerFields;
Vector<char> buffer;
if (file) {
NPError readResult = handlePostReadFile(buffer, len, buf);
if(readResult != NPERR_NO_ERROR)
return readResult;
} else {
buffer.resize(len);
memcpy(buffer.data(), buf, len);
}
const char* postData = buffer.data();
int postDataLength = buffer.size();
if (allowHeaders) {
if (startsWithBlankLine(buffer)) {
postData++;
postDataLength--;
} else {
int location = locationAfterFirstBlankLine(buffer);
if (location != -1) {
// If the blank line is somewhere in the middle of the buffer, everything before is the header
headerFields = parseRFC822HeaderFields(buffer, location);
unsigned dataLength = buffer.size() - location;
// Sometimes plugins like to set Content-Length themselves when they post,
// but WebFoundation does not like that. So we will remove the header
// and instead truncate the data to the requested length.
String contentLength = headerFields.get("Content-Length");
if (!contentLength.isNull())
dataLength = min(contentLength.toInt(), (int)dataLength);
headerFields.remove("Content-Length");
postData += location;
postDataLength = dataLength;
}
}
}
frameLoadRequest.resourceRequest().setHTTPMethod("POST");
frameLoadRequest.resourceRequest().setURL(makeURL(m_baseURL, url));
frameLoadRequest.resourceRequest().addHTTPHeaderFields(headerFields);
frameLoadRequest.resourceRequest().setHTTPBody(FormData::create(postData, postDataLength));
frameLoadRequest.setFrameName(target);
return load(frameLoadRequest, sendNotification, notifyData);
}
示例2: parsePostBuffer
static NPError parsePostBuffer(bool isFile, const char *buffer, uint32_t length, bool parseHeaders, HTTPHeaderMap& headerFields, Vector<uint8_t>& bodyData)
{
RefPtr<SharedBuffer> fileContents;
const char* postBuffer = 0;
uint32_t postBufferSize = 0;
if (isFile) {
fileContents = SharedBuffer::createWithContentsOfFile(String::fromUTF8(buffer));
if (!fileContents)
return NPERR_FILE_NOT_FOUND;
postBuffer = fileContents->data();
postBufferSize = fileContents->size();
// FIXME: The NPAPI spec states that the file should be deleted here.
} else {
postBuffer = buffer;
postBufferSize = length;
}
if (parseHeaders) {
if (startsWithBlankLine(postBuffer, postBufferSize)) {
postBuffer++;
postBufferSize--;
} else {
int location = locationAfterFirstBlankLine(postBuffer, postBufferSize);
if (location != -1) {
// If the blank line is somewhere in the middle of the buffer, everything before is the header
headerFields = parseRFC822HeaderFields(postBuffer, location);
unsigned dataLength = postBufferSize - location;
// Sometimes plugins like to set Content-Length themselves when they post,
// but WebFoundation does not like that. So we will remove the header
// and instead truncate the data to the requested length.
String contentLength = headerFields.get("Content-Length");
if (!contentLength.isNull())
dataLength = min(contentLength.toInt(), (int)dataLength);
headerFields.remove("Content-Length");
postBuffer += location;
postBufferSize = dataLength;
}
}
}
ASSERT(bodyData.isEmpty());
bodyData.append(postBuffer, postBufferSize);
return NPERR_NO_ERROR;
}