@@ -94,7 +94,6 @@ AEGIS_DECL rest_reply rest_controller::execute(rest::request_params && params)
9494 request_stream << " Accept: */*\r\n " ;
9595 request_stream << " Authorization: Bot " << _token << " \r\n " ;
9696 request_stream << " User-Agent: DiscordBot (https://github.com/zeroxs/aegis.cpp, " << AEGIS_VERSION_LONG << " )\r\n " ;
97- request_stream << " Connection: close\r\n " ;
9897
9998 if (params.file .has_value ())
10099 {
@@ -106,6 +105,7 @@ AEGIS_DECL rest_reply rest_controller::execute(rest::request_params && params)
106105
107106 ss << " --" << boundary << " \r\n " ;
108107 ss << R"( Content-Disposition: form-data; name="file"; filename=")" << utility::escape_quotes (file.name ) << " \"\r\n " ;
108+ request_stream << " Connection: close\r\n " ;
109109 ss << " Content-Type: text/plain\r\n\r\n " ;
110110 ss.write (file.data .data (), file.data .size ());
111111 ss << " \r\n " ;
@@ -118,9 +118,12 @@ AEGIS_DECL rest_reply rest_controller::execute(rest::request_params && params)
118118 else if (!params.body .empty ())
119119 {
120120 request_stream << " Content-Length: " << params.body .size () << " \r\n " ;
121+ request_stream << " Connection: close\r\n " ;
121122 request_stream << " Content-Type: application/json\r\n\r\n " ;
122123 request_stream << params.body ;
123124 }
125+ else
126+ request_stream << " Connection: close\r\n\r\n " ;
124127
125128 asio::write (socket, request);
126129 asio::streambuf response;
@@ -228,14 +231,16 @@ AEGIS_DECL rest_reply rest_controller::execute2(rest::request_params && params)
228231 request_stream << " Accept: */*\r\n " ;
229232 for (auto & h : params.headers )
230233 request_stream << h << " \r\n " ;
231- request_stream << " Connection: close\r\n " ;
232234
233235 if (!params.body .empty ())
234236 {
237+ request_stream << " Connection: close\r\n " ;
235238 request_stream << " Content-Length: " << params.body .size () << " \r\n " ;
236239 request_stream << " Content-Type: application/json\r\n\r\n " ;
237240 request_stream << params.body ;
238241 }
242+ else
243+ request_stream << " Connection: close\r\n\r\n " ;
239244
240245 asio::write (socket, request);
241246 asio::streambuf response;
@@ -269,15 +274,16 @@ AEGIS_DECL rest_reply rest_controller::execute2(rest::request_params && params)
269274 request_stream << " Accept: */*\r\n " ;
270275 for (auto & h : params.headers )
271276 request_stream << h << " \r\n " ;
272-
273- request_stream << " Connection: close\r\n " ;
274277
275278 if (!params.body .empty ())
276279 {
280+ request_stream << " Connection: close\r\n " ;
277281 request_stream << " Content-Length: " << params.body .size () << " \r\n " ;
278282 request_stream << " Content-Type: application/json\r\n\r\n " ;
279283 request_stream << params.body ;
280284 }
285+ else
286+ request_stream << " Connection: close\r\n\r\n " ;
281287
282288 asio::write (socket, request);
283289 asio::streambuf response;
0 commit comments