6
6
/* By: aoumad <[email protected] > +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
@@ -105,7 +105,9 @@ namespace http{
105
105
// if (!recv_ret)
106
106
// {
107
107
unchunk (clients[i].fd );
108
- // }
108
+ // }
109
+ // std::cout<<"--**---"<<requist_data[clients[i].fd]<<"---***"<<std::endl;
110
+
109
111
}
110
112
}
111
113
else if (clients[i].revents & POLLOUT && read_info[clients[i].fd ] == true )
@@ -171,7 +173,6 @@ namespace http{
171
173
{
172
174
std::size_t content_length = requist_data[sockfd].find (" Content-Length: " );
173
175
std::size_t transfer_encoding = requist_data[sockfd].find (" Transfer-Encoding: chunked" );
174
-
175
176
176
177
if (content_length != std::string::npos && transfer_encoding != std::string::npos)
177
178
{
@@ -180,7 +181,6 @@ namespace http{
180
181
else
181
182
return (0 );
182
183
}
183
-
184
184
if (content_length == std::string::npos)
185
185
{
186
186
if (transfer_encoding != std::string::npos)
@@ -196,8 +196,10 @@ namespace http{
196
196
return (0 );
197
197
}
198
198
}
199
+
199
200
return (2 );
200
201
}
202
+
201
203
202
204
int http_sever::recv_data (int sockfd)
203
205
{
@@ -223,6 +225,10 @@ namespace http{
223
225
}
224
226
else if (transfer_encoding_chunked (sockfd) == 0 )
225
227
{
228
+ if (read_info[sockfd] == true )
229
+ {
230
+ return (0 );
231
+ }
226
232
return (1 );
227
233
}
228
234
else if (transfer_encoding_chunked (sockfd) == 2 )
@@ -334,7 +340,7 @@ namespace http{
334
340
335
341
response << " HTTP/1.1 200 OK\r\n " ;
336
342
response << " Content-Type: text/html; charset=UTF-8\r\n " ;
337
-
343
+ response << " Content-Length: 76 \r\n " ;
338
344
response << " \r\n " ;
339
345
response << " <html><body><h1>Hello younes </h1>" ;
340
346
response << " <h1>from HTTP server!</h4>" ;
0 commit comments