Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match forward headers case insensitively. #6889

Merged
merged 16 commits into from
Feb 27, 2024
Merged
17 changes: 9 additions & 8 deletions qa/L0_parameters/parameters_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
yinggeh marked this conversation as resolved.
Show resolved Hide resolved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -54,13 +54,14 @@ async def asyncSetUp(self):
self.async_grpc = asyncgrpcclient.InferenceServerClient(url="localhost:8001")

self.parameter_list = []
self.parameter_list.append({"key1": "value1", "key2": "value2"})
self.parameter_list.append({"key1": 1, "key2": 2})
self.parameter_list.append({"key1": 123.123, "key2": 321.321})
self.parameter_list.append({"key1": True, "key2": "value2"})
self.parameter_list.append({"triton_": True, "key2": "value2"})

if TEST_HEADER == "1":
if TEST_HEADER in ["0","1"]:
yinggeh marked this conversation as resolved.
Show resolved Hide resolved
self.parameter_list.append({"key1": "value1", "key2": "value2"})
self.parameter_list.append({"key1": 1, "key2": 2})
self.parameter_list.append({"key1": 123.123, "key2": 321.321})
self.parameter_list.append({"key1": True, "key2": "value2"})
self.parameter_list.append({"triton_": True, "key2": "value2"})

if TEST_HEADER in ["1","2"]:
yinggeh marked this conversation as resolved.
Show resolved Hide resolved
self.headers = {
"header_1": "value_1",
"header_2": "value_2",
Expand Down
4 changes: 3 additions & 1 deletion qa/L0_parameters/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ mkdir -p "${MODELDIR}/ensemble/1"
# https://jirasw.nvidia.com/browse/DLIS-4673

RET=0
for i in {0..1}; do
for i in {0..2}; do
yinggeh marked this conversation as resolved.
Show resolved Hide resolved

# TEST_HEADER is a parameter used by `parameters_test.py` that controls
# whether the script will test for inclusion of headers in parameters or not.
if [ $i == 1 ]; then
SERVER_ARGS="--model-repository=${MODELDIR} --exit-timeout-secs=120 --grpc-header-forward-pattern my_header.* --http-header-forward-pattern my_header.*"
elif [ $i == 2 ]; then
SERVER_ARGS="--model-repository=${MODELDIR} --exit-timeout-secs=120 --grpc-header-forward-pattern MY_HEADER.* --http-header-forward-pattern MY_HEADER.*"
else
SERVER_ARGS="--model-repository=${MODELDIR} --exit-timeout-secs=120"
fi
Expand Down
11 changes: 9 additions & 2 deletions src/command_line_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,11 @@ TritonParser::Parse(int argc, char** argv)
triton::server::grpc::Options& lgrpc_options = lparams.grpc_options_;
#endif // TRITON_ENABLE_GRPC

#if defined TRITON_ENABLE_HTTP || defined TRITON_ENABLE_GRPC
// According to HTTP specification header names are case-insensitive.
const std::string case_insensitive_prefix{"(?i)"};
yinggeh marked this conversation as resolved.
Show resolved Hide resolved
#endif // TRITON_ENABLE_HTTP || TRITON_ENABLE_GRPC

#ifdef TRITON_ENABLE_VERTEX_AI
// Set different default value if specific flag is set
{
Expand Down Expand Up @@ -1345,7 +1350,8 @@ TritonParser::Parse(int argc, char** argv)
lparams.http_address_ = optarg;
break;
case OPTION_HTTP_HEADER_FORWARD_PATTERN:
lparams.http_forward_header_pattern_ = optarg;
lparams.http_forward_header_pattern_ =
std::move(case_insensitive_prefix + optarg);
yinggeh marked this conversation as resolved.
Show resolved Hide resolved
break;
break;
case OPTION_HTTP_THREAD_COUNT:
Expand Down Expand Up @@ -1484,7 +1490,8 @@ TritonParser::Parse(int argc, char** argv)
break;
}
case OPTION_GRPC_HEADER_FORWARD_PATTERN:
lgrpc_options.forward_header_pattern_ = optarg;
lgrpc_options.forward_header_pattern_ =
std::move(case_insensitive_prefix + optarg);
break;
#endif // TRITON_ENABLE_GRPC

Expand Down
Loading