当前位置: 首页>>代码示例>>C++>>正文


C++ MessageHeader::has方法代码示例

本文整理汇总了C++中MessageHeader::has方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageHeader::has方法的具体用法?C++ MessageHeader::has怎么用?C++ MessageHeader::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageHeader的用法示例。


在下文中一共展示了MessageHeader::has方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readPart

void MailMessage::readPart(std::istream& istr, const MessageHeader& header, PartHandler& handler)
{
	std::string encoding;
	if (header.has(HEADER_CONTENT_TRANSFER_ENCODING))
	{
		encoding = header.get(HEADER_CONTENT_TRANSFER_ENCODING);
		// get rid of a parameter if one is set
		std::string::size_type pos = encoding.find(';');
		if (pos != std::string::npos)
			encoding.resize(pos);
	}
	if (icompare(encoding, CTE_QUOTED_PRINTABLE) == 0)
	{
		QuotedPrintableDecoder decoder(istr);
		handlePart(decoder, header, handler);
	}
	else if (icompare(encoding, CTE_BASE64) == 0)
	{
		Base64Decoder decoder(istr);
		handlePart(decoder, header, handler);
	}
	else
	{
		handlePart(istr, header, handler);
	}
}
开发者ID:1514louluo,项目名称:poco,代码行数:26,代码来源:MailMessage.cpp

示例2: handlePart

	void handlePart(const MessageHeader& header, std::istream& stream)
	{
		_type = header.get("Content-Type", "(unspecified)");
		if (header.has("Content-Disposition"))
		{
			std::string disp;
			NameValueCollection params;
			MessageHeader::splitParameters(header["Content-Disposition"], disp, params);
			_name = params.get("name", "(unnamed)");
			_fileName = params.get("filename", "(unnamed)");
		}
		
		CountingInputStream istr(stream);
		NullOutputStream ostr;
		StreamCopier::copyStream(istr, ostr);
		_length = istr.chars();
	}
开发者ID:PsyCommando,项目名称:ppmdu,代码行数:17,代码来源:HTTPFormServer.cpp

示例3: handlePart

	void handlePart(const MessageHeader& header, std::istream& stream)
	{
		std::string symbolicName;
		if (_form.has("symbolicName"))
			symbolicName = _form.get("symbolicName");

		if (header.has("Content-Disposition"))
		{
			if (symbolicName.empty())
			{
				_pBundle = _pInstaller->installBundle(stream);
			}
			else
			{
				_pBundle = _pInstaller->replaceBundle(symbolicName, stream);
			}
		}
	}
开发者ID:JoneXie,项目名称:macchina.io,代码行数:18,代码来源:BundleInstallHandler.cpp

示例4: readMultipart

void HTMLForm::readMultipart(std::istream& istr, PartHandler& handler)
{
	static const int eof = std::char_traits<char>::eof();

	int fields = 0;
	MultipartReader reader(istr, _boundary);
	while (reader.hasNextPart())
	{
		if (_fieldLimit > 0 && fields == _fieldLimit)
			throw HTMLFormException("Too many form fields");
		MessageHeader header;
		reader.nextPart(header);
		std::string disp;
		NameValueCollection params;
		if (header.has("Content-Disposition"))
		{
			std::string cd = header.get("Content-Disposition");
			MessageHeader::splitParameters(cd, disp, params);
		}
		if (params.has("filename"))
		{
			handler.handlePart(header, reader.stream());
			// Ensure that the complete part has been read.
			while (reader.stream().good()) reader.stream().get();
		}
		else
		{
			std::string name = params["name"];
			std::string value;
			std::istream& istr = reader.stream();
			int ch = istr.get();
			while (ch != eof)
			{
				value += (char) ch;
				ch = istr.get();
			}
			add(name, value);
		}
		++fields;
	}
}
开发者ID:Chingliu,项目名称:poco,代码行数:41,代码来源:HTMLForm.cpp

示例5: handlePart

//------------------------------------------------------------------------------
void ofxWebServerUploadRouteHandler::handlePart(const MessageHeader& header, std::istream& stream) {
    NameValueCollection::ConstIterator iter = header.begin();
    
    //        while(iter != header.end()) {
    //            cout << (*iter).first << "=" << (*iter).second << endl;
    //            ++iter;
    //        }
    //
    
    if(header.has("Content-Type")) {
        string contentType = header["Content-Type"];
        if(!isContentTypeValid(contentType)) {
            ofLogError("ofxWebServerUploadRouteHandler::handlePart") << "Invalid content type: " << contentType;
            return; // reject
        }
    } else {
        ofLogError("ofxWebServerUploadRouteHandler::handlePart") << "No Content-Type header.";
        return;
    }
    
    // is this an uploaded file?
    if(header.has("Content-Disposition")) {// && header.has("form-data")) {
        string contentDisposition = header["Content-Disposition"];
        NameValueCollection parameters;
        MessageHeader::splitParameters(contentDisposition.begin(),contentDisposition.end(),parameters);
        
        if(parameters.has("filename")) {
            try {
            
                ofFile file(settings.uploadFolder + "/" + parameters["filename"], ofFile::WriteOnly);

                cout << file.getAbsolutePath() << endl;
                
                streamsize sz = StreamCopier::copyStream(stream,file);
                
                // The section below is from StreamCopier::copyStream,
                // and can be used for upload progress feedback
                //                int bufferSize = 8192;
                //                Buffer<char> buffer(bufferSize);
                //                streamsize len = 0;
                //                stream.read(buffer.begin(), bufferSize);
                //                streamsize n = stream.gcount();
                //                while (n > 0) {
                //                    len += n;
                //                    file.write(buffer.begin(), n);
                //                    if (stream && file) {
                //                        stream.read(buffer.begin(), bufferSize);
                //                        n = stream.gcount();
                //                        cout << n << endl;
                //                    }
                //                    else n = 0;
                //                }
                
                file.close();
                
            } catch(const Exception& exc) {
                ofLogError("ofxWebServerUploadRouteHandler::handlePart") << exc.displayText();
            } catch(const exception& exc) {
                ofLogError("ofxWebServerUploadRouteHandler::handlePart") << exc.what();
            } catch(...) {
                ofLogError("ofxWebServerUploadRouteHandler::handlePart") << "Uncaught thread exception: Unknown exception.";
            }
            
        } else {
            // error
        }
    }
    
}
开发者ID:bakercp,项目名称:ofxWebServer,代码行数:70,代码来源:ofxWebServerUploadRouteHandler.cpp


注:本文中的MessageHeader::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。