Remove the request shared_ptr from the multipart parser (#1984)
This commit is contained in:
parent
4cbac301fb
commit
9f2872639a
|
@ -178,8 +178,9 @@ class DROGON_EXPORT MultiPartParser
|
|||
int parse(const HttpRequestPtr &req,
|
||||
const char *boundaryData,
|
||||
size_t boundaryLen);
|
||||
int parseEntity(const char *begin, const char *end);
|
||||
HttpRequestPtr requestPtr_;
|
||||
int parseEntity(const HttpRequestPtr &req,
|
||||
const char *begin,
|
||||
const char *end);
|
||||
};
|
||||
|
||||
/// In order to be compatible with old interfaces
|
||||
|
|
|
@ -104,7 +104,9 @@ static std::pair<std::string_view, std::string_view> parseLine(
|
|||
return std::make_pair(std::string_view(), std::string_view());
|
||||
}
|
||||
|
||||
int MultiPartParser::parseEntity(const char *begin, const char *end)
|
||||
int MultiPartParser::parseEntity(const HttpRequestPtr &req,
|
||||
const char *begin,
|
||||
const char *end)
|
||||
{
|
||||
static const char entityName[] = "name=";
|
||||
static const char fileName[] = "filename=";
|
||||
|
@ -174,7 +176,7 @@ int MultiPartParser::parseEntity(const char *begin, const char *end)
|
|||
fileNameEnd = std::find(fileNamePos, valueEnd, ';');
|
||||
}
|
||||
std::string fName{fileNamePos, fileNameEnd};
|
||||
filePtr->setRequest(requestPtr_);
|
||||
filePtr->setRequest(req);
|
||||
filePtr->setItemName(std::move(name));
|
||||
filePtr->setFileName(std::move(fName));
|
||||
filePtr->setFile(headEnd + 2,
|
||||
|
@ -218,7 +220,6 @@ int MultiPartParser::parse(const HttpRequestPtr &req,
|
|||
std::string_view boundary{boundaryData, boundaryLen};
|
||||
if (boundary.size() > 2 && boundary[0] == '\"')
|
||||
boundary = boundary.substr(1, boundary.size() - 2);
|
||||
requestPtr_ = req;
|
||||
std::string_view::size_type pos1, pos2;
|
||||
pos1 = 0;
|
||||
auto content = static_cast<HttpRequestImpl *>(req.get())->bodyView();
|
||||
|
@ -241,7 +242,7 @@ int MultiPartParser::parse(const HttpRequestPtr &req,
|
|||
pos2 -= 4;
|
||||
flag = true;
|
||||
}
|
||||
if (parseEntity(content.data() + pos1, content.data() + pos2) != 0)
|
||||
if (parseEntity(req, content.data() + pos1, content.data() + pos2) != 0)
|
||||
return -1;
|
||||
if (flag)
|
||||
pos2 += 4;
|
||||
|
|
2
trantor
2
trantor
|
@ -1 +1 @@
|
|||
Subproject commit b4e9c8b86300419a1792b73cf60747c9c350686d
|
||||
Subproject commit c92280119a6ebaf71fe6aca0d128222edd028b22
|
Loading…
Reference in New Issue