本文整理汇总了C++中IOBuffer::getNumBytesStored方法的典型用法代码示例。如果您正苦于以下问题:C++ IOBuffer::getNumBytesStored方法的具体用法?C++ IOBuffer::getNumBytesStored怎么用?C++ IOBuffer::getNumBytesStored使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOBuffer
的用法示例。
在下文中一共展示了IOBuffer::getNumBytesStored方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseHTTPRequest
bool ofxAMFHTTPRequest::parseHTTPRequest(IOBuffer& buffer, IOBuffer& amfResultBuffer) {
// step 1. parse http headers
if(num_bytes_in_header == 0) {
num_bytes_in_header = buffer.consumeUntil("\r\n\r\n", raw_headers);
}
// step 2. parse headers when all received.
if(num_bytes_in_header != 0) {
if(parseHTTPHeaders()) {
num_bytes_in_body = headers["content-length"].getAsUInt32();
}
}
else {
return false;
}
// step 3. parse body when received content-length.
if(num_bytes_in_body != 0) {
uint32_t bytes_stored = buffer.getNumBytesStored();
uint32_t bytes_total = num_bytes_in_header + num_bytes_in_body;
uint32_t bytes_left = bytes_total - bytes_stored;
if(bytes_left == 0) {
amfResultBuffer.storeBuffer(buffer, num_bytes_in_body);
//cout << headers.toString() << endl;
return true;
}
}
return false;
}
示例2: createHTTPResponse
// prepends the headers to the buffer for a http resonse.
IOBuffer ofxAMFHTTPResponse::createHTTPResponse(IOBuffer& buffer) {
IOBuffer http_buffer;
http_buffer.setup(buffer.getNumBytesStored());
http_buffer.storeString("HTTP/1.1 200 OK\r\n");
stringstream ss;
ss << "Content-Length: " << buffer.getNumBytesStored() << "\r\n";
http_buffer.storeString(ss.str());
http_buffer.storeString("Connection: close\r\n");
http_buffer.storeString("Content-type: application/x-amf\r\n");
http_buffer.storeString("\r\n");
http_buffer.storeBuffer(buffer);
return http_buffer;
}
示例3: storeBuffer
// copy data from another buffer.
void IOBuffer::storeBuffer(IOBuffer& other) {
storeBuffer(other, other.getNumBytesStored());
}