fix for MultipartWriter leading CR-LF bug
This commit is contained in:
Родитель
d615c47379
Коммит
8a498c2e19
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// MultipartReader.h
|
||||
//
|
||||
// $Id: //poco/1.3/Net/include/Poco/Net/MultipartReader.h#1 $
|
||||
// $Id: //poco/1.3/Net/include/Poco/Net/MultipartReader.h#2 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: Messages
|
||||
|
@ -104,7 +104,7 @@ class Net_API MultipartReader
|
|||
/// message into its single parts.
|
||||
///
|
||||
/// The format of multipart messages is described
|
||||
/// in section 7.2 of RFC 1341.
|
||||
/// in section 5.1 of RFC 2046.
|
||||
///
|
||||
/// To split a multipart message into its parts,
|
||||
/// do the following:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// MultipartWriter.h
|
||||
//
|
||||
// $Id: //poco/1.3/Net/include/Poco/Net/MultipartWriter.h#1 $
|
||||
// $Id: //poco/1.3/Net/include/Poco/Net/MultipartWriter.h#2 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: Messages
|
||||
|
@ -56,7 +56,7 @@ class Net_API MultipartWriter
|
|||
/// messages to an output stream.
|
||||
///
|
||||
/// The format of multipart messages is described
|
||||
/// in section 7.2 of RFC 1341.
|
||||
/// in section 5.1 of RFC 2046.
|
||||
///
|
||||
/// To create a multipart message, first create
|
||||
/// a MultipartWriter object.
|
||||
|
@ -112,6 +112,7 @@ private:
|
|||
|
||||
std::ostream& _ostr;
|
||||
std::string _boundary;
|
||||
bool _firstPart;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// MultipartWriter.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Net/src/MultipartWriter.cpp#1 $
|
||||
// $Id: //poco/1.3/Net/src/MultipartWriter.cpp#2 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: Messages
|
||||
|
@ -50,14 +50,16 @@ namespace Net {
|
|||
|
||||
MultipartWriter::MultipartWriter(std::ostream& ostr):
|
||||
_ostr(ostr),
|
||||
_boundary(createBoundary())
|
||||
_boundary(createBoundary()),
|
||||
_firstPart(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MultipartWriter::MultipartWriter(std::ostream& ostr, const std::string& boundary):
|
||||
_ostr(ostr),
|
||||
_boundary(boundary)
|
||||
_boundary(boundary),
|
||||
_firstPart(true)
|
||||
{
|
||||
if (_boundary.empty())
|
||||
_boundary = createBoundary();
|
||||
|
@ -71,7 +73,11 @@ MultipartWriter::~MultipartWriter()
|
|||
|
||||
void MultipartWriter::nextPart(const MessageHeader& header)
|
||||
{
|
||||
_ostr << "\r\n--" << _boundary << "\r\n";
|
||||
if (_firstPart)
|
||||
_firstPart = false;
|
||||
else
|
||||
_ostr << "\r\n";
|
||||
_ostr << "--" << _boundary << "\r\n";
|
||||
header.write(_ostr);
|
||||
_ostr << "\r\n";
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// HTMLFormTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Net/testsuite/src/HTMLFormTest.cpp#1 $
|
||||
// $Id: //poco/1.3/Net/testsuite/src/HTMLFormTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -133,7 +133,7 @@ void HTMLFormTest::testWriteMultipart()
|
|||
std::ostringstream ostr;
|
||||
form.write(ostr, "MIME_boundary_0123456789");
|
||||
std::string s = ostr.str();
|
||||
assert (s == "\r\n"
|
||||
assert (s ==
|
||||
"--MIME_boundary_0123456789\r\n"
|
||||
"Content-Disposition: form-data; name=\"field1\"\r\n"
|
||||
"\r\n"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// MailMessageTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Net/testsuite/src/MailMessageTest.cpp#1 $
|
||||
// $Id: //poco/1.3/Net/testsuite/src/MailMessageTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -284,7 +284,6 @@ void MailMessageTest::testWriteMultiPart()
|
|||
"Subject: Test Message\r\n"
|
||||
"To: John Doe <john.doe@no.where>\r\n"
|
||||
"\r\n"
|
||||
"\r\n"
|
||||
"--$\r\n"
|
||||
"Content-Disposition: inline\r\n"
|
||||
"Content-Transfer-Encoding: 8bit\r\n"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// MultipartWriterTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Net/testsuite/src/MultipartWriterTest.cpp#1 $
|
||||
// $Id: //poco/1.3/Net/testsuite/src/MultipartWriterTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
|
@ -63,7 +63,7 @@ void MultipartWriterTest::testWriteOnePart()
|
|||
ostr << "this is part 1";
|
||||
w.close();
|
||||
std::string s = ostr.str();
|
||||
assert (s == "\r\n--MIME_boundary_01234567\r\nname1: value1\r\n\r\nthis is part 1\r\n--MIME_boundary_01234567--\r\n");
|
||||
assert (s == "--MIME_boundary_01234567\r\nname1: value1\r\n\r\nthis is part 1\r\n--MIME_boundary_01234567--\r\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +80,7 @@ void MultipartWriterTest::testWriteTwoParts()
|
|||
ostr << "this is part 2";
|
||||
w.close();
|
||||
std::string s = ostr.str();
|
||||
assert (s == "\r\n--MIME_boundary_01234567\r\nname1: value1\r\n\r\nthis is part 1\r\n--MIME_boundary_01234567\r\n\r\nthis is part 2\r\n--MIME_boundary_01234567--\r\n");
|
||||
assert (s == "--MIME_boundary_01234567\r\nname1: value1\r\n\r\nthis is part 1\r\n--MIME_boundary_01234567\r\n\r\nthis is part 2\r\n--MIME_boundary_01234567--\r\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.3-20070104 (2007-01-04)
|
||||
1.3-20070111 (2007-01-11)
|
||||
|
|
Загрузка…
Ссылка в новой задаче