Skip to content

Commit

Permalink
HttpRequest end() for is_chunked_output_active
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 20, 2024
1 parent 444e896 commit c7d311e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/AudioTools/CoreAudio/AudioHttp/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class HttpRequest : public BaseStream {
/// same as end()
void end() override {
if (connected()) {
// write final 0 chunk if necessary
if (is_chunked_output_active) client_ptr->println(0, HEX);
client_ptr->flush();
LOGI("stop");
client_ptr->stop();
}
Expand Down Expand Up @@ -284,6 +287,7 @@ class HttpRequest : public BaseStream {
size_t result = 0;
if (isChunked()) {
if (len > 0) {
is_chunked_output_active = true;
client_ptr->println(len, HEX);
result = client_ptr->write(data, len);
client_ptr->println();
Expand Down Expand Up @@ -343,6 +347,7 @@ class HttpRequest : public BaseStream {
int32_t clientTimeout = URL_CLIENT_TIMEOUT; // 60000;
void (*http_connect_callback)(HttpRequest &request, Url &url,
HttpRequestHeader &request_header) = nullptr;
bool is_chunked_output_active = false;

// opens a connection to the indicated host
virtual int connect(const char *ip, uint16_t port, int32_t timeout) {
Expand Down

0 comments on commit c7d311e

Please sign in to comment.