mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-02 17:50:53 +02:00
Proper fix for #1337
This commit is contained in:
parent
38acb93a39
commit
bfc2ee99a0
@ -230,6 +230,10 @@ void HTMLForm::prepareSubmit(HTTPRequest& request)
|
|||||||
{
|
{
|
||||||
request.setChunkedTransferEncoding(true);
|
request.setChunkedTransferEncoding(true);
|
||||||
}
|
}
|
||||||
|
if (!request.getChunkedTransferEncoding())
|
||||||
|
{
|
||||||
|
request.setContentLength(calculateContentLength());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -245,7 +249,7 @@ void HTMLForm::prepareSubmit(HTTPRequest& request)
|
|||||||
|
|
||||||
std::streamsize HTMLForm::calculateContentLength()
|
std::streamsize HTMLForm::calculateContentLength()
|
||||||
{
|
{
|
||||||
if (_boundary.empty())
|
if (_encoding == ENCODING_MULTIPART && _boundary.empty())
|
||||||
throw HTMLFormException("Form must be prepared");
|
throw HTMLFormException("Form must be prepared");
|
||||||
|
|
||||||
HTMLFormCountingOutputStream c;
|
HTMLFormCountingOutputStream c;
|
||||||
@ -385,7 +389,7 @@ void HTMLForm::writeUrl(std::ostream& ostr)
|
|||||||
|
|
||||||
void HTMLForm::writeMultipart(std::ostream& ostr)
|
void HTMLForm::writeMultipart(std::ostream& ostr)
|
||||||
{
|
{
|
||||||
HTMLFormCountingOutputStream *costr(dynamic_cast<HTMLFormCountingOutputStream*>(&ostr));
|
HTMLFormCountingOutputStream* pCountingOutputStream(dynamic_cast<HTMLFormCountingOutputStream*>(&ostr));
|
||||||
|
|
||||||
MultipartWriter writer(ostr, _boundary);
|
MultipartWriter writer(ostr, _boundary);
|
||||||
for (NameValueCollection::ConstIterator it = begin(); it != end(); ++it)
|
for (NameValueCollection::ConstIterator it = begin(); it != end(); ++it)
|
||||||
@ -414,17 +418,19 @@ void HTMLForm::writeMultipart(std::ostream& ostr)
|
|||||||
header.set("Content-Disposition", disp);
|
header.set("Content-Disposition", disp);
|
||||||
header.set("Content-Type", ita->pSource->mediaType());
|
header.set("Content-Type", ita->pSource->mediaType());
|
||||||
writer.nextPart(header);
|
writer.nextPart(header);
|
||||||
if (costr)
|
if (pCountingOutputStream)
|
||||||
{
|
{
|
||||||
// count only, don't move stream position
|
// count only, don't move stream position
|
||||||
std::streamsize partlen = ita->pSource->getContentLength();
|
std::streamsize partlen = ita->pSource->getContentLength();
|
||||||
if (partlen != PartSource::UNKNOWN_CONTENT_LENGTH)
|
if (partlen != PartSource::UNKNOWN_CONTENT_LENGTH)
|
||||||
costr->addChars(static_cast<int>(partlen));
|
pCountingOutputStream->addChars(static_cast<int>(partlen));
|
||||||
else
|
else
|
||||||
costr->setValid(false);
|
pCountingOutputStream->setValid(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
StreamCopier::copyStream(ita->pSource->stream(), ostr);
|
StreamCopier::copyStream(ita->pSource->stream(), ostr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
_boundary = writer.boundary();
|
_boundary = writer.boundary();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user