Move Boundary retrival into Utilities
This commit is contained in:
18
src/main.cpp
18
src/main.cpp
@ -1019,7 +1019,6 @@ int main(int argc, char *argv[]) {
|
||||
ID_SELECT_FREELANCER_NAME
|
||||
});
|
||||
|
||||
|
||||
string freelancerName, freelancerID;
|
||||
pqxx::result freelancerNameResult = Database::executePreparedStatement_SELECT_FREELANCER_NAME(databaseConnection, cookieCtx.get_cookie(COOKIE_FREELANCER_EMAIL));
|
||||
freelancerName = freelancerNameResult.at(0).at(0).c_str();
|
||||
@ -1027,25 +1026,14 @@ int main(int argc, char *argv[]) {
|
||||
freelancerID = freelancerIDResult.at(0).at(0).c_str();
|
||||
|
||||
string formDataBoundary;
|
||||
|
||||
//get boundary
|
||||
for (const auto &header: postRequest.headers) {
|
||||
if (header.first == "Content-Type") {
|
||||
string boundaryHeaderName = "boundary=";
|
||||
std::size_t contentTypeStart = header.second.find(boundaryHeaderName);
|
||||
if (contentTypeStart == string::npos) {
|
||||
return crow::response(400, "Boundary could not be found");
|
||||
break;
|
||||
}
|
||||
contentTypeStart += boundaryHeaderName.size() + 1;
|
||||
formDataBoundary = header.second.substr(contentTypeStart, header.second.size());
|
||||
}
|
||||
}
|
||||
if (!Utilities::getBoundaryFromPostRequest(formDataBoundary, postRequest))
|
||||
return crow::response(400, "Boundary could not be found");
|
||||
|
||||
//check if boundary is in body
|
||||
size_t positionBoundaryStart = postRequest.body.find(formDataBoundary);
|
||||
if (positionBoundaryStart == string::npos)
|
||||
return crow::response(400, "Content Boundary could not be found in the body of the request");
|
||||
|
||||
size_t positionBoundaryEnd = postRequest.body.find(formDataBoundary + "--");
|
||||
if (positionBoundaryEnd == string::npos)
|
||||
return crow::response(400, "Content Boundary could not be found in the body of the request");
|
||||
|
Reference in New Issue
Block a user