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 +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/11 13:29:21 by mmoussou #+# #+# */
|
/* 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 != x->end(); \
|
||||||
it++
|
it++
|
||||||
|
|
||||||
#define BUFFER_SIZE 4096
|
#define BUFFER_SIZE 1024
|
||||||
|
|
||||||
namespace webserv {} // namespace webserv
|
namespace webserv {} // namespace webserv
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/30 09:50:20 by adjoly #+# #+# */
|
/* 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));
|
_route = _srv->whatRoute(URL(_target));
|
||||||
if (_route->getMaxBody() != -1 &&
|
/*if (_route->getMaxBody() != -1 &&
|
||||||
(int32_t)_body.length() > _route->getMaxBody()) {
|
(int32_t)_body.length() > _route->getMaxBody()) {
|
||||||
_method = "413";
|
_method = "413";
|
||||||
_log->warn("post body too large");
|
_log->warn("post body too large");
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
_url = new URL(_target);
|
_url = new URL(_target);
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ std::string Post::extractFilename(const std::string &header) {
|
|||||||
|
|
||||||
void Post::handleMultipartData(const std::string &body,
|
void Post::handleMultipartData(const std::string &body,
|
||||||
const std::string &boundary) {
|
const std::string &boundary) {
|
||||||
_log->info("handling MultipartData upload...");
|
_log->debug("handling MultipartData upload...");
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
std::string delim = "--" + boundary;
|
std::string delim = "--" + boundary;
|
||||||
delim.erase(delim.size() - 1);
|
delim.erase(delim.size() - 1);
|
||||||
@ -132,18 +132,19 @@ void Post::handleMultipartData(const std::string &body,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Post::handleBinaryUpload() {
|
void Post::handleBinaryUpload() {
|
||||||
_log->info("handling binary upload...");
|
_log->debug("handling binary upload...");
|
||||||
std::cout << (this->_route->getUpRoot() + this->_target) << std::endl;
|
std::cout << (this->_route->getUpRoot() + this->_target) << std::endl;
|
||||||
std::ofstream outfile((this->_route->getUpRoot() + this->_target).c_str(),
|
std::ofstream outfile((this->_route->getUpRoot() + this->_target).c_str(),
|
||||||
std::ios::binary);
|
std::ios::binary);
|
||||||
|
|
||||||
if (outfile.is_open()) {
|
if (outfile.is_open()) {
|
||||||
outfile.write(this->_body.data(), this->_body.length());
|
outfile.write(this->_body.data(), this->_body.length());
|
||||||
outfile.close();
|
|
||||||
} else {
|
} else {
|
||||||
_log->error("open failed D:");
|
_log->error("open failed D:");
|
||||||
|
outfile.close();
|
||||||
throw std::runtime_error("open failed");
|
throw std::runtime_error("open failed");
|
||||||
}
|
}
|
||||||
|
outfile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Response Post::execute(void) {
|
Response Post::execute(void) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/17 11:12:41 by mmoussou #+# #+# */
|
/* 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");
|
_log->error("failed to receive request");
|
||||||
throw std::runtime_error("failed to receive request");
|
throw std::runtime_error("failed to receive request");
|
||||||
}
|
}
|
||||||
|
size_t tmp_size = received_data.length();
|
||||||
_getRequest(received_data);
|
_getRequest(received_data);
|
||||||
|
|
||||||
if (_request == not_nullptr)
|
if (_request == not_nullptr)
|
||||||
@ -117,8 +118,8 @@ void Client::parse(void)
|
|||||||
(_request->getMethod() == "DELETE" && !_route->getMethods()[2]))
|
(_request->getMethod() == "DELETE" && !_route->getMethods()[2]))
|
||||||
this->_request->setMethod("405");
|
this->_request->setMethod("405");
|
||||||
|
|
||||||
// if (received_data.length() > (unsigned long)(_route->getMaxBody()))
|
if (tmp_size > (unsigned long)(_route->getMaxBody()))
|
||||||
// this->_request->setMethod("413");
|
this->_request->setMethod("413");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::requestParsed(void) {
|
bool Client::requestParsed(void) {
|
||||||
|
Reference in New Issue
Block a user