From: <c99...@us...> - 2007-08-25 00:14:10
|
Revision: 492 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=492&view=rev Author: c99koder Date: 2007-08-24 17:14:06 -0700 (Fri, 24 Aug 2007) Log Message: ----------- Tiki: net: Fix HTTP POST size calculation and header format Modified Paths: -------------- tiki/src/net/http/useragent.cpp Modified: tiki/src/net/http/useragent.cpp =================================================================== --- tiki/src/net/http/useragent.cpp 2007-08-24 02:55:09 UTC (rev 491) +++ tiki/src/net/http/useragent.cpp 2007-08-25 00:14:06 UTC (rev 492) @@ -152,21 +152,21 @@ if(buf->getUsedDataLen() > 0) { std::stringstream temp; temp << "--" << req->getBoundaryMarker() << "\r\n"; - temp << "Content-Disposition: form-data: name=\""; + temp << "Content-Disposition: form-data; name=\""; if(!buf->getFieldName().empty()) { temp << buf->getFieldName(); } else { temp << "File"; } - temp << "\"; filename=\"" << buf->getFileNameShort() << "\"\r\nContent-Type: " << buf->getContentType() << "\r\n"; + temp << "\"; filename=\"" << buf->getFileNameShort() << "\"\r\nContent-Type: " << buf->getContentType() << "\r\n\r\n"; std::string headerText = temp.str(); //Tiki::Debug::printf("CONTENT_HEADER:\n%s", headerText.c_str()); socket->send(new Buffer(headerText.length(), (uint8 *)headerText.c_str())); socket->send(buf); } } - std::string footerText = "--"; + std::string footerText = "\r\n--"; footerText.append(req->getBoundaryMarker()); footerText.append("--\r\n"); //Tiki::Debug::printf("CONTENT_FOOTER:\n%s", footerText.c_str()); @@ -243,22 +243,23 @@ std::list<std::string> content = request->getContentPartNames(); if(!mode.compare("POST") && (content.size() > 1 || request->isForcedMultiPartUpload())) { - uint64 totalSize = 8; // add 8 to account for "--<boundary>--\r\n" + uint64 totalSize = 8 + request->getBoundaryMarker().length(); // account for the ending boundary for(std::list<std::string>::iterator iter = content.begin(); iter != content.end(); ++iter) { Buffer *buf = request->getContentPart(*iter); if(buf->getUsedDataLen() > 0) { + totalSize += request->getBoundaryMarker().length() + 4; totalSize += buf->getUsedDataLen(); std::stringstream temp; - temp << "Content-Disposition: form-data: name=\""; + temp << "Content-Disposition: form-data; name=\""; if(!buf->getFieldName().empty()) { temp << buf->getFieldName(); } else { temp << "File"; } - temp << "\"; filename=\"" << buf->getFileNameShort() << "\"\r\nContent-Type: " << buf->getContentType() << "\r\n"; + temp << "\"; filename=\"" << buf->getFileNameShort() << "\"\r\nContent-Type: " << buf->getContentType() << "\r\n\r\n"; // add section header size totalSize += temp.str().length(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |