@@ -627,8 +627,18 @@ WiFiClient* HTTPClient::getStreamPtr(void)
627627 */
628628int HTTPClient::writeToStream (Stream * stream)
629629{
630+ return writeToPrint (stream);
631+ }
630632
631- if (!stream) {
633+ /* *
634+ * write all message body / payload to Print
635+ * @param print Print *
636+ * @return bytes written ( negative values are error codes )
637+ */
638+ int HTTPClient::writeToPrint (Print * print)
639+ {
640+
641+ if (!print) {
632642 return returnError (HTTPC_ERROR_NO_STREAM);
633643 }
634644
@@ -645,7 +655,7 @@ int HTTPClient::writeToStream(Stream * stream)
645655 if (_transferEncoding == HTTPC_TE_IDENTITY) {
646656 // len < 0: transfer all of it, with timeout
647657 // len >= 0: max:len, with timeout
648- ret = _client->sendSize (stream , len);
658+ ret = _client->sendSize (print , len);
649659
650660 // do we have an error?
651661 if (_client->getLastSendReport () != Stream::Report::Success) {
@@ -673,7 +683,7 @@ int HTTPClient::writeToStream(Stream * stream)
673683 // data left?
674684 if (len > 0 ) {
675685 // read len bytes with timeout
676- int r = _client->sendSize (stream , len);
686+ int r = _client->sendSize (print , len);
677687 if (_client->getLastSendReport () != Stream::Report::Success)
678688 // not all data transferred
679689 return returnError (StreamReportToHttpClientReport (_client->getLastSendReport ()));
0 commit comments