Skip to content

Commit 73d8e01

Browse files
authored
Merge branch 'master' into aoumad
2 parents 7c51543 + e28afd9 commit 73d8e01

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

server/http_server.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: aoumad <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/04/04 18:41:23 by yismaili #+# #+# */
9-
/* Updated: 2023/05/08 18:19:59 by aoumad ### ########.fr */
9+
/* Updated: 2023/05/07 22:47:38 by yismaili ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -105,7 +105,9 @@ namespace http{
105105
// if (!recv_ret)
106106
// {
107107
unchunk(clients[i].fd);
108-
// }
108+
//}
109+
// std::cout<<"--**---"<<requist_data[clients[i].fd]<<"---***"<<std::endl;
110+
109111
}
110112
}
111113
else if (clients[i].revents & POLLOUT && read_info[clients[i].fd] == true)
@@ -171,7 +173,6 @@ namespace http{
171173
{
172174
std::size_t content_length = requist_data[sockfd].find("Content-Length: ");
173175
std::size_t transfer_encoding = requist_data[sockfd].find("Transfer-Encoding: chunked");
174-
175176

176177
if (content_length != std::string::npos && transfer_encoding != std::string::npos)
177178
{
@@ -180,7 +181,6 @@ namespace http{
180181
else
181182
return (0);
182183
}
183-
184184
if (content_length == std::string::npos)
185185
{
186186
if (transfer_encoding != std::string::npos)
@@ -196,8 +196,10 @@ namespace http{
196196
return (0);
197197
}
198198
}
199+
199200
return (2);
200201
}
202+
201203

202204
int http_sever::recv_data(int sockfd)
203205
{
@@ -223,6 +225,10 @@ namespace http{
223225
}
224226
else if (transfer_encoding_chunked(sockfd) == 0)
225227
{
228+
if (read_info[sockfd] == true)
229+
{
230+
return (0);
231+
}
226232
return (1);
227233
}
228234
else if (transfer_encoding_chunked(sockfd) == 2)
@@ -334,7 +340,7 @@ namespace http{
334340

335341
response << "HTTP/1.1 200 OK\r\n";
336342
response << "Content-Type: text/html; charset=UTF-8\r\n";
337-
343+
response << "Content-Length: 76\r\n";
338344
response << "\r\n";
339345
response << "<html><body><h1>Hello younes </h1>";
340346
response << "<h1>from HTTP server!</h4>";

0 commit comments

Comments
 (0)