@@ -373,6 +373,46 @@ int HTTPClient::sendRequest(const char * type, String payload)
373
373
return sendRequest (type, (uint8_t *) payload.c_str (), payload.length ());
374
374
}
375
375
376
+ /* *
377
+ * sendRequest
378
+ * @param type const char * "GET", "POST", ....
379
+ * @param type const char * "/URI"
380
+ * @param payload uint8_t * data for the message body if null not send
381
+ * @param size size_t size for the message body if 0 not send
382
+ * @return -1 if no info or > 0 when Content-Length is set by server
383
+ */
384
+ int HTTPClient::sendRequest (const char * type, uint8_t * uri,uint8_t * payload, size_t size)
385
+ {
386
+ Serial.printf (" [HTTP-Client][sendRequest] switch uri <%s> to <%s>\n " ,_uri.c_str (),uri);
387
+ _uri = String ((char *)uri);
388
+
389
+ // connect to server
390
+ if (!connect ()) {
391
+ return returnError (HTTPC_ERROR_CONNECTION_REFUSED);
392
+ }
393
+
394
+ if (payload && size > 0 ) {
395
+ addHeader (F (" Content-Length" ), String (size));
396
+ }
397
+
398
+ // send Header
399
+ if (!sendHeader (type)) {
400
+ return returnError (HTTPC_ERROR_SEND_HEADER_FAILED);
401
+ }
402
+
403
+ // send Payload if needed
404
+ if (payload && size > 0 ) {
405
+ if (_tcp->write (&payload[0 ], size) != size) {
406
+ return returnError (HTTPC_ERROR_SEND_PAYLOAD_FAILED);
407
+ }
408
+ }
409
+
410
+ // handle Server Response (Header)
411
+ return returnError (handleHeaderResponse ());
412
+ }
413
+
414
+
415
+
376
416
/* *
377
417
* sendRequest
378
418
* @param type const char * "GET", "POST", ....
0 commit comments