Skip to content

Commit 9017683

Browse files
committed
fix(http/response/type): StatusResponse segfault fixed
1 parent 1d1ef1f commit 9017683

17 files changed

Lines changed: 80 additions & 226 deletions

‎Makefile‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# By: ysumeral <ysumeral@student.42istanbul.c +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
88
# Created: 2026/03/18 13:17:49 by ysumeral #+# #+# #
9-
# Updated: 2026/06/14 19:06:46 by ysumeral ### ########.fr #
9+
# Updated: 2026/06/15 19:50:45 by ysumeral ### ########.fr #
1010
# #
1111
#******************************************************************************#
1212

@@ -39,7 +39,6 @@ IFLAGS = -I $(INC_DIR) \
3939
-I $(INC_DIR)http \
4040
-I $(INC_DIR)http/handler \
4141
-I $(INC_DIR)http/request \
42-
-I $(INC_DIR)http/request/state \
4342
-I $(INC_DIR)http/response \
4443
-I $(INC_DIR)http/response/type
4544

@@ -59,9 +58,6 @@ CORE_SRC = $(CORE_DIR)Server.cpp \
5958

6059
HTTP_SRC = $(HTTP_REQUEST_DIR)Request.cpp \
6160
$(HTTP_REQUEST_DIR)RequestBuilder.cpp \
62-
$(HTTP_REQUEST_STATE_DIR)BodyState.cpp \
63-
$(HTTP_REQUEST_STATE_DIR)HeaderState.cpp \
64-
$(HTTP_REQUEST_STATE_DIR)RequestLineState.cpp \
6561
$(HTTP_HANDLER_DIR)GetHandler.cpp \
6662
$(HTTP_HANDLER_DIR)HeadHandler.cpp \
6763
$(HTTP_HANDLER_DIR)PostHandler.cpp \

‎conf/default.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ server {
88
location /
99
{
1010
autoindex on;
11-
index index.html about.html;
11+
index about.html index.html;
1212
}
1313
location /km
1414
{

‎include/http/request/IRequestState.hpp‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎include/http/request/RequestBuilder.hpp‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/* ************************************************************************** */
1+
/******************************************************************************/
22
/* */
33
/* ::: :::::::: */
44
/* RequestBuilder.hpp :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: ysumeral <ysumeral@student.42istanbul.c +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2026/03/22 08:47:02 by ysumeral #+# #+# */
9-
/* Updated: 2026/06/13 21:28:53 by ysumeral ### ########.fr */
9+
/* Updated: 2026/06/15 20:44:26 by ysumeral ### ########.fr */
1010
/* */
11-
/* ************************************************************************** */
11+
/******************************************************************************/
1212

1313
#ifndef REQUESTBUILDER_HPP
1414
# define REQUESTBUILDER_HPP
@@ -68,8 +68,7 @@ namespace http
6868
void addHeader(const std::string &key, const std::string &value);
6969
bool buildRequestLine(std::string &line);
7070
bool buildHeaderLine(std::string &line);
71-
bool buildBody(std::string &rawReadBuffer);
72-
bool validateParseResult();
71+
bool buildBody(std::string &rawReadBuffer, bool isChunked);
7372
};
7473
}
7574

‎include/http/request/state/BodyState.hpp‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎include/http/request/state/HeaderState.hpp‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎include/http/request/state/RequestLineState.hpp‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎src/core/Connection.cpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/* ************************************************************************** */
1+
/******************************************************************************/
22
/* */
33
/* ::: :::::::: */
44
/* Connection.cpp :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: ysumeral <ysumeral@student.42istanbul.c +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2026/03/18 06:30:45 by ysumeral #+# #+# */
9-
/* Updated: 2026/06/13 16:48:23 by ysumeral ### ########.fr */
9+
/* Updated: 2026/06/15 21:00:42 by ysumeral ### ########.fr */
1010
/* */
11-
/* ************************************************************************** */
11+
/******************************************************************************/
1212

1313
#include "Connection.hpp"
1414
#include "SuccessResponse.hpp"
@@ -46,6 +46,9 @@ namespace core
4646
void Connection::appendRequestBuffer(const std::string &buffer)
4747
{
4848
this->_readBuffer += buffer;
49+
std::cout << "---------------- REQUEST ----------------" << std::endl;
50+
std::cout << this->_readBuffer << std::endl;
51+
std::cout << "---------------- REQUEST END ----------------" << std::endl;
4952
}
5053

5154
void Connection::resetForNextRequest()

‎src/core/Server.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/* ************************************************************************** */
1+
/******************************************************************************/
22
/* */
33
/* ::: :::::::: */
44
/* Server.cpp :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: ysumeral <ysumeral@student.42istanbul.c +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2026/03/23 15:35:32 by ysumeral #+# #+# */
9-
/* Updated: 2026/05/31 21:00:36 by ysumeral ### ########.fr */
9+
/* Updated: 2026/06/15 15:26:55 by ysumeral ### ########.fr */
1010
/* */
11-
/* ************************************************************************** */
11+
/******************************************************************************/
1212

1313
#include "Server.hpp"
1414

‎src/core/ServerHandler.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/* ************************************************************************** */
1+
/******************************************************************************/
22
/* */
33
/* ::: :::::::: */
44
/* ServerHandler.cpp :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: ysumeral <ysumeral@student.42istanbul.c +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2026/03/23 15:35:30 by ysumeral #+# #+# */
9-
/* Updated: 2026/06/13 22:19:18 by ysumeral ### ########.fr */
9+
/* Updated: 2026/06/15 21:08:41 by ysumeral ### ########.fr */
1010
/* */
11-
/* ************************************************************************** */
11+
/******************************************************************************/
1212

1313
#include "ServerHandler.hpp"
1414
#include "ConfigLocation.hpp"
@@ -164,9 +164,9 @@ namespace core
164164
if (bytesRead > 0)
165165
{
166166
std::string rawData(buffer, bytesRead);
167-
std::cout << "---------------- REQUEST ----------------" << std::endl;
167+
std::cout << "---------------- RAWREQUEST ----------------" << std::endl;
168168
std::cout << rawData << std::endl;
169-
std::cout << "---------------- REQUEST END ----------------" << std::endl;
169+
std::cout << "---------------- RAWREQUEST END ----------------" << std::endl;
170170
conn->appendRequestBuffer(rawData);
171171
conn->process();
172172
if (conn->getState() == core::WRITING)

0 commit comments

Comments
 (0)