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


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

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


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

示例1: session

void POP3ClientSessionTest::testRetrieveHeader()
{
	DialogServer server;
	server.addResponse("+OK POP3 Ready...");
	server.addResponse("+OK USER");
	server.addResponse("+OK PASS");
	server.addResponse(
		"+OK Here comes the message\r\n"
		"From: [email protected]\r\n"
		"To: [email protected]\r\n"
		"Subject: test\r\n"
		"\r\n"
		"."
	);
	server.addResponse("+OK QUIT");
	POP3ClientSession session("localhost", server.port());
	session.login("user", "secret");
	server.clearCommands();
	MessageHeader header;
	session.retrieveHeader(1, header);
	std::string cmd = server.popCommand();
	assert (cmd == "TOP 1 0");
	assert (header.get("From") == "[email protected]");
	assert (header.get("To") == "[email protected]");
	assert (header.get("Subject") == "test");
	session.close();
}
开发者ID:12307,项目名称:poco,代码行数:27,代码来源:POP3ClientSessionTest.cpp

示例2: 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

示例3: 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

示例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 MyPartHandler::handlePart(const MessageHeader& messageHeader, std::istream& stream)
{
    stringstream headerSS;
    messageHeader.write(headerSS);
    _headers.push_back(headerSS.str());

    string contentType = messageHeader.get("Content-Type", "nil");

    if((MyString::ToLower(contentType)).find("multipart") == 0) {
        MultipartReader multipartReader(stream);

        while(multipartReader.hasNextPart()) {
            MessageHeader subMessageHeader;
            multipartReader.nextPart(subMessageHeader);

            string subContentType = subMessageHeader.get("Content-Type", "nil");
            // Convert to lower case for comparison only
            string lc_subctype = MyString::ToLower(subContentType);

            //Priority is text/plain format, else save text/html format
            if(lc_subctype == "nil") {
                continue;
            } else if(lc_subctype.find("application") != string::npos && lc_subctype.find("name") != string::npos) {
                // Save attachment(s) in sub-content part
                string disp;
                string filename;
                string attachment;
                NameValueCollection params;

                MessageHeader::splitParameters(lc_subctype, disp, params);
                filename = params.get("name", "nil");
                if(filename != "nil") {
                    // Filename and Attachments might be encoded in Base64 or QuotedPrintable
                    _filenames.push_back(DecodeString(filename));
                    string encoder = MyString::ToLower(subMessageHeader.get("Content-Transfer-Encoding", "nil"));
                    if(encoder == "base64") {
                        Poco::Base64Decoder base64Decoder(multipartReader.stream());
                        StreamCopier::copyToString(base64Decoder, attachment);
                    } else if(encoder == "quoted-printable") {
                        Poco::Net::QuotedPrintableDecoder qpDecoder(multipartReader.stream());
                        StreamCopier::copyToString(qpDecoder, attachment);
                    } else {
                        StreamCopier::copyToString(multipartReader.stream(), attachment);
                    }

                    if (!attachment.empty()) {
                        _attachments.push_back(attachment);
                    }
                }
            } else if(lc_subctype.find("boundary") != string::npos) {
                int bStart = 0;
                if(_myboundary.empty()) {
                    bStart = subContentType.find('_');
                    _myboundary = MyString::FixField(subContentType, bStart, (subContentType.length() - (bStart + 1)));
                }
            } else if(lc_subctype.find("text/plain") == 0) {
                string charset;

                if(subContentType.find("charset") != string::npos) {
                    //Outlook: Content-Type text/plain charset="us-ascii"
                    //Yahoo: Content-Type text/plain charset=iso-8859-1
                    string subct_clean = MyString::RemoveChar(subContentType, '"');
                    int charpos = subct_clean.find("charset=") + 8; //+8 to bypass the word "charset="
                    charset = MyString::FixField(subct_clean, charpos, (subContentType.length() - charpos) );
                }

                //If body variable is not empty, it has the text/plain format of the email body.
                string cte = subMessageHeader.get("Content-Transfer-Encoding", "nil");
                //For some reasons, emails from outlook (content transfer encoding is specified as quoted-printable in header), it generates nil result in QuotedPrintableDecoder
                if(charset.compare("us-ascii") != 0) {
                    if(cte == "base64")	{
                        Poco::Base64Decoder base64Decoder(multipartReader.stream());
                        StreamCopier::copyToString(base64Decoder, _body);
                    } else if(cte == "quoted-printable") {
                        Poco::Net::QuotedPrintableDecoder qpDecoder(multipartReader.stream());
                        StreamCopier::copyToString(qpDecoder, _body);
                    } else {
                        StreamCopier::copyToString(multipartReader.stream(), _body);
                    }
                } else {
                    StreamCopier::copyToString(multipartReader.stream(), _body);
                }

                if(!_myboundary.empty() && _myboundary.compare(multipartReader.boundary()) != 0) {
                    _body = MyString::Trim(MyString::FixField(_body, 0, (_body.find(_myboundary) - 2))); //-2 for the boundary heading, e.g. --_000_OD67Eexchau_
                }
            } else {
                if(_body.empty() || _body.length() > 0) break;
                // Will hit error "Malformed message: Field value too long/no CRLF found" under MesssageHeader.read() in MessageHeader.cpp
                // if "continue" is used.  "text/plain" part will always come before "text/html" part
                //Keep this code for reference of retrieving text/html content, ignore text/html part at this moment
                /*
                  else if(subContentType.find("text/html") == 0) {
                    string cte = subMessageHeader.get("Content-Transfer-Encoding", "nil");
                    if(cte == "base64") {
                      Poco::Base64Decoder base64Decoder(multipartReader.stream());
                      StreamCopier::copyToString(base64Decoder, _body);
                    } else if(cte == "quoted-printable") {
                  Poco::Net::QuotedPrintableDecoder qpDecoder(multipartReader.stream());
                  StreamCopier::copyToString(qpDecoder, _body);
//.........这里部分代码省略.........
开发者ID:hchaudhry,项目名称:mail_client,代码行数:101,代码来源:myparthandler.cpp


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