@@ -84,7 +84,8 @@ String UniversalTelegramBot::sendGetToTelegram(String command) {
84
84
String a = " " ;
85
85
char c;
86
86
int ch_count = 0 ;
87
- client->println (" GET /" + command);
87
+ client->print (F (" GET /" ));
88
+ client->println (command);
88
89
now = millis ();
89
90
avail = false ;
90
91
while (millis () - now < longPoll * 1000 + waitForResponse) {
@@ -130,11 +131,11 @@ String UniversalTelegramBot::sendPostToTelegram(String command, JsonObject paylo
130
131
}
131
132
if (client->connected ()) {
132
133
// POST URI
133
- client->print (" POST /" + command);
134
+ client->print (F (" POST /" ));
135
+ client->print (command);
134
136
client->println (F (" HTTP/1.1" ));
135
137
// Host header
136
- client->print (F (" Host:" ));
137
- client->println (HOST);
138
+ client->println (F (" Host:" HOST));
138
139
// JSON content type
139
140
client->println (F (" Content-Type: application/json" ));
140
141
@@ -221,22 +222,27 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
221
222
}
222
223
if (client->connected ()) {
223
224
224
- String start_request = " " ;
225
- String end_request = " " ;
226
-
227
- start_request = start_request + " --" + boundry + " \r\n " ;
228
- start_request = start_request + " content-disposition: form-data; name=\" chat_id\" " + " \r\n " ;
229
- start_request = start_request + " \r\n " ;
230
- start_request = start_request + chat_id + " \r\n " ;
231
- start_request = start_request + " --" + boundry + " \r\n " ;
232
- start_request = start_request + " content-disposition: form-data; name=\" " + binaryProperyName + " \" ; filename=\" " + fileName + " \" " + " \r\n " ;
233
- start_request = start_request + " Content-Type: " + contentType + " \r\n " ;
234
- start_request = start_request + " \r\n " ;
235
-
236
- end_request = end_request + " \r\n " ;
237
- end_request = end_request + " --" + boundry + " --" + " \r\n " ;
238
-
239
- client->print (" POST /bot" + _token + " /" + command);
225
+ String start_request = F (" --" );
226
+
227
+ start_request += boundry;
228
+ start_request += F (" \r\n content-disposition: form-data; name=\" chat_id\"\r\n\r\n " );
229
+ start_request += chat_id;
230
+ start_request += F (" \r\n " " --" );
231
+ start_request += boundry;
232
+ start_request += F (" \r\n content-disposition: form-data; name=\" " );
233
+ start_request += binaryProperyName;
234
+ start_request += F (" \" ; filename=\" " );
235
+ start_request += fileName;
236
+ start_request += F (" \"\r\n " " Content-Type: " );
237
+ start_request += contentType;
238
+ start_request += F (" \r\n " " \r\n " );
239
+
240
+ String end_request = F (" \r\n " " --" );
241
+ end_request += boundry;
242
+ end_request += F (" --" " \r\n " );
243
+
244
+ client->print (F (" POST /" ));
245
+ client->print (buildCommand (command));
240
246
client->println (F (" HTTP/1.1" ));
241
247
// Host header
242
248
client->print (F (" Host: " ));
@@ -248,10 +254,11 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
248
254
#ifdef _debug
249
255
Serial.println (" Content-Length: " + String (contentLength));
250
256
#endif
251
- client->print (" Content-Length: " );
257
+ client->print (F ( " Content-Length: " ) );
252
258
client->println (String (contentLength));
253
- client->println (" Content-Type: multipart/form-data; boundary=" + boundry);
254
- client->println (" " );
259
+ client->print (F (" Content-Type: multipart/form-data; boundary=" ));
260
+ client->println (boundry);
261
+ client->println (F (" " ));
255
262
client->print (start_request);
256
263
257
264
#ifdef _debug
0 commit comments