mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-07-15 19:46:32 +02:00
「🔨」 fix: fixed things
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/11 13:29:21 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/05/27 19:25:07 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/07/12 17:55:18 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -36,6 +36,6 @@
|
||||
it != x->end(); \
|
||||
it++
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
namespace webserv {} // namespace webserv
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/30 09:50:20 by adjoly #+# #+# */
|
||||
/* Updated: 2025/07/12 13:48:25 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/07/12 18:00:40 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -59,12 +59,12 @@ void Post::parse(std::string const &data) {
|
||||
}
|
||||
|
||||
_route = _srv->whatRoute(URL(_target));
|
||||
if (_route->getMaxBody() != -1 &&
|
||||
/*if (_route->getMaxBody() != -1 &&
|
||||
(int32_t)_body.length() > _route->getMaxBody()) {
|
||||
_method = "413";
|
||||
_log->warn("post body too large");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
_url = new URL(_target);
|
||||
|
||||
@ -100,7 +100,7 @@ std::string Post::extractFilename(const std::string &header) {
|
||||
|
||||
void Post::handleMultipartData(const std::string &body,
|
||||
const std::string &boundary) {
|
||||
_log->info("handling MultipartData upload...");
|
||||
_log->debug("handling MultipartData upload...");
|
||||
size_t i = 0;
|
||||
std::string delim = "--" + boundary;
|
||||
delim.erase(delim.size() - 1);
|
||||
@ -132,18 +132,19 @@ void Post::handleMultipartData(const std::string &body,
|
||||
}
|
||||
|
||||
void Post::handleBinaryUpload() {
|
||||
_log->info("handling binary upload...");
|
||||
_log->debug("handling binary upload...");
|
||||
std::cout << (this->_route->getUpRoot() + this->_target) << std::endl;
|
||||
std::ofstream outfile((this->_route->getUpRoot() + this->_target).c_str(),
|
||||
std::ios::binary);
|
||||
|
||||
if (outfile.is_open()) {
|
||||
outfile.write(this->_body.data(), this->_body.length());
|
||||
outfile.close();
|
||||
} else {
|
||||
_log->error("open failed D:");
|
||||
outfile.close();
|
||||
throw std::runtime_error("open failed");
|
||||
}
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
Response Post::execute(void) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/17 11:12:41 by mmoussou #+# #+# */
|
||||
/* Updated: 2025/07/12 13:44:56 by adjoly ### ########.fr */
|
||||
/* Updated: 2025/07/12 17:51:43 by mmoussou ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -90,6 +90,7 @@ void Client::parse(void)
|
||||
_log->error("failed to receive request");
|
||||
throw std::runtime_error("failed to receive request");
|
||||
}
|
||||
size_t tmp_size = received_data.length();
|
||||
_getRequest(received_data);
|
||||
|
||||
if (_request == not_nullptr)
|
||||
@ -117,8 +118,8 @@ void Client::parse(void)
|
||||
(_request->getMethod() == "DELETE" && !_route->getMethods()[2]))
|
||||
this->_request->setMethod("405");
|
||||
|
||||
// if (received_data.length() > (unsigned long)(_route->getMaxBody()))
|
||||
// this->_request->setMethod("413");
|
||||
if (tmp_size > (unsigned long)(_route->getMaxBody()))
|
||||
this->_request->setMethod("413");
|
||||
}
|
||||
|
||||
bool Client::requestParsed(void) {
|
||||
|
Reference in New Issue
Block a user