Skip to content

Commit

Permalink
Исправлены ошибки компиляции
Browse files Browse the repository at this point in the history
  • Loading branch information
mtriston committed Jun 12, 2021
1 parent a1b1fec commit bebc70e
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 48 deletions.
8 changes: 5 additions & 3 deletions ConnectionSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "IWork.hpp"
#include "Config_parser.hpp"

#define BUF_SIZE 8096
#define MAX_BODY 15000000

ConnectionSocket::ConnectionSocket(int socket, int port, Config_parser *parser)
: ASocket(socket, port, parser), _state(READ_REQUEST), _response(this) {}

Expand Down Expand Up @@ -46,7 +49,6 @@ void ConnectionSocket::readRequest()

bool ConnectionSocket::_isRequestRead()
{
size_t maxClientBody = config_->getServerConf("", port_)->getMax_client_body();
unsigned long headerEndPos = _buffer.find("\r\n\r\n");

if (headerEndPos != std::string::npos) {
Expand All @@ -56,7 +58,7 @@ bool ConnectionSocket::_isRequestRead()
if (contentLengthPos != std::string::npos && contentLengthPos < headerEndPos) {
char *end_p;
size_t contentLength = std::strtol(_buffer.c_str() + contentLengthPos + 15, &end_p, 10);
if (contentLength > maxClientBody) {
if (contentLength > MAX_BODY) {
return true;
}
if (_buffer.size() == headerEndPos + 4 + contentLength) {
Expand All @@ -67,7 +69,7 @@ bool ConnectionSocket::_isRequestRead()
unsigned long transferEncodingPos = _buffer.find("Transfer-Encoding: chunked");
if (transferEncodingPos != std::string::npos && transferEncodingPos < headerEndPos) {

if (_buffer.size() > maxClientBody * 2) {
if (_buffer.size() > MAX_BODY * 2) {
return true;
}
if (_buffer.compare(_buffer.size() - 5, 5, "0\r\n\r\n") == 0) {
Expand Down
2 changes: 0 additions & 2 deletions ConnectionSocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#ifndef WEBSERV__CONNECTIONSOCKET_HPP_
#define WEBSERV__CONNECTIONSOCKET_HPP_

#define BUF_SIZE 8000

class Config_parser;

#include <string>
Expand Down
7 changes: 5 additions & 2 deletions Response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "CGI_unit.hpp"
#include "utils.hpp"

#define BUF_SIZE 8096


Response::Response() {}

Response::Response(ConnectionSocket *socket)
Expand Down Expand Up @@ -311,10 +314,10 @@ std::string Response::getHeaders()

bool Response::isPayloadTooLarge() const
{
size_t maxClientBody = config->getMax_client_body();
size_t maxClientBody = config->getMax_client_body(request->getPath());

return request->getContentLength() > maxClientBody ||
request->getBody().size() > maxClientBody * 2;
request->getBody().size() > maxClientBody;
}

std::string Response::generateErrorPage(int code)
Expand Down
1 change: 0 additions & 1 deletion Response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <sys/types.h>
#include <map>

#define BUF_SIZE 2048
#define FILE_INFO struct dirent

class ConnectionSocket;
Expand Down
37 changes: 0 additions & 37 deletions webserv.conf

This file was deleted.

2 changes: 1 addition & 1 deletion www/error_pages/403.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Forbidden</title>
<title>FROM FILE</title>
</head>
<body>
<h1>403 Forbidden</h1>
Expand Down
2 changes: 1 addition & 1 deletion www/error_pages/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Not found</title>
<title>FROM FILE</title>
</head>
<body>
<h1>404 Not found</h1>
Expand Down
2 changes: 1 addition & 1 deletion www/error_pages/405.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Not Allowed</title>
<title>FROM FILE</title>
</head>
<body>
<h1>405 Not Allowed</h1>
Expand Down

0 comments on commit bebc70e

Please sign in to comment.