Skip to content

Commit

Permalink
Fix GetInferenceHeaderLength override
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccorm4 committed Sep 20, 2023
1 parent c8633c9 commit df6858c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2310,11 +2310,10 @@ HTTPAPIServer::GetContentLength(

TRITONSERVER_Error*
HTTPAPIServer::GetInferenceHeaderLength(
evhtp_request_t* req, evbuffer* decompressed_buffer, size_t* header_length)
evhtp_request_t* req, int32_t content_length, size_t* header_length)
{
// Get content length as a default header_length if no header specified
int32_t content_length = 0;
RETURN_IF_ERR(GetContentLength(req, decompressed_buffer, &content_length));
// Find Inference-Header-Content-Length in header.
// Set to content length in case that the header is not specified
*header_length = content_length;

// Find Inference-Header-Content-Length in header.
Expand Down Expand Up @@ -3049,10 +3048,16 @@ HTTPAPIServer::HandleInfer(
// Decompress request body if it is compressed in supported type
evbuffer* decompressed_buffer = nullptr;
RETURN_AND_RESPOND_IF_ERR(req, DecompressBuffer(req, &decompressed_buffer));

// Get content length as a default header_length if no header specified
int32_t content_length = 0;
RETURN_AND_RESPOND_IF_ERR(
req, GetContentLength(req, decompressed_buffer, &content_length));

// Get the header length
size_t header_length = 0;
RETURN_AND_RESPOND_IF_ERR(
req, GetInferenceHeaderLength(req, decompressed_buffer, &header_length));
req, GetInferenceHeaderLength(req, content_length, &header_length));

// HTTP request paused when creating inference request. Resume it on exit if
// this function returns early due to error. Otherwise resumed in callback.
Expand Down
9 changes: 4 additions & 5 deletions src/http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,13 @@ class HTTPAPIServer : public HTTPServer {
// Get the inference header length. Return 0 if the whole request body is
// the inference header.
virtual TRITONSERVER_Error* GetInferenceHeaderLength(
evhtp_request_t* req, evbuffer* decompressed_buffer,
size_t* header_length);
virtual TRITONSERVER_Error* GetContentLength(
evhtp_request_t* req, evbuffer* decompressed_buffer,
int32_t* content_length);
evhtp_request_t* req, int32_t content_length, size_t* header_length);
virtual DataCompressor::Type GetRequestCompressionType(evhtp_request_t* req);
virtual DataCompressor::Type GetResponseCompressionType(evhtp_request_t* req);

TRITONSERVER_Error* GetContentLength(
evhtp_request_t* req, evbuffer* decompressed_buffer,
int32_t* content_length);
TRITONSERVER_Error* DecompressBuffer(
evhtp_request_t* req, evbuffer** decompressed_buffer);
TRITONSERVER_Error* CheckTransactionPolicy(
Expand Down

0 comments on commit df6858c

Please sign in to comment.