Skip to content

Commit

Permalink
[fix](stream_load)fix bug when stream without content-length or chunk…
Browse files Browse the repository at this point in the history
…ed Transfer Encoding
  • Loading branch information
alexxing662 committed Nov 30, 2023
1 parent c30299c commit 7172f56
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions be/src/http/action/stream_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ Status StreamLoadAction::_handle(std::shared_ptr<StreamLoadContext> ctx) {
LOG(WARNING) << "recevie body don't equal with body bytes, body_bytes=" << ctx->body_bytes
<< ", receive_bytes=" << ctx->receive_bytes << ", id=" << ctx->id;
return Status::InternalError("receive body don't equal with body bytes");
} else if (ctx->body_bytes == 0 && ctx->receive_bytes && ctx->is_chunked_transfer == false) {
LOG(WARNING) << "please set content_length correctly or set transfer-encoding=chunked, "
"body_bytes="
<< ctx->body_bytes << ", receive_bytes=" << ctx->receive_bytes
<< ", id=" << ctx->id;
return Status::InternalError(
"please set content_length correctly or set transfer-encoding=chunked");
}

// if we use non-streaming, MessageBodyFileSink.finish will close the file
Expand Down Expand Up @@ -301,6 +308,14 @@ Status StreamLoadAction::_on_header(HttpRequest* http_req, std::shared_ptr<Strea
}
}

if (http_req->header(HttpHeaders::CONTENT_LENGTH).empty() && !ctx->is_chunked_transfer) {
LOG(WARNING) << "content_length is empty and transfer-encoding!=chunked, please set "
"content_length or transfer-encoding=chunked";
return Status::InternalError(
"content_length is empty and transfer-encoding!=chunked, please set content_length "
"or transfer-encoding=chunked");
}

if (!http_req->header(HTTP_TIMEOUT).empty()) {
try {
ctx->timeout_second = std::stoi(http_req->header(HTTP_TIMEOUT));
Expand Down

0 comments on commit 7172f56

Please sign in to comment.