Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
bfc7adaa
Commit
bfc7adaa
authored
9 years ago
by
Makarand Dharmapurikar
Browse files
Options
Downloads
Patches
Plain Diff
Added option to echo back user agent for testing
parent
31dd6660
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/interop/server.cc
+11
-0
11 additions, 0 deletions
test/cpp/interop/server.cc
with
11 additions
and
0 deletions
test/cpp/interop/server.cc
+
11
−
0
View file @
bfc7adaa
...
@@ -82,6 +82,7 @@ static const char* kRandomFile = "test/cpp/interop/rnd.dat";
...
@@ -82,6 +82,7 @@ static const char* kRandomFile = "test/cpp/interop/rnd.dat";
const
char
kEchoInitialMetadataKey
[]
=
"x-grpc-test-echo-initial"
;
const
char
kEchoInitialMetadataKey
[]
=
"x-grpc-test-echo-initial"
;
const
char
kEchoTrailingBinMetadataKey
[]
=
"x-grpc-test-echo-trailing-bin"
;
const
char
kEchoTrailingBinMetadataKey
[]
=
"x-grpc-test-echo-trailing-bin"
;
const
char
kEchoUserAgentKey
[]
=
"x-grpc-test-echo-useragent"
;
void
MaybeEchoMetadata
(
ServerContext
*
context
)
{
void
MaybeEchoMetadata
(
ServerContext
*
context
)
{
const
auto
&
client_metadata
=
context
->
client_metadata
();
const
auto
&
client_metadata
=
context
->
client_metadata
();
...
@@ -98,6 +99,15 @@ void MaybeEchoMetadata(ServerContext* context) {
...
@@ -98,6 +99,15 @@ void MaybeEchoMetadata(ServerContext* context) {
kEchoTrailingBinMetadataKey
,
kEchoTrailingBinMetadataKey
,
grpc
::
string
(
iter
->
second
.
begin
(),
iter
->
second
.
end
()));
grpc
::
string
(
iter
->
second
.
begin
(),
iter
->
second
.
end
()));
}
}
// Check if client sent a magic key in the header that makes us echo
// back the user-agent (for testing purpose)
iter
=
client_metadata
.
find
(
kEchoUserAgentKey
);
if
(
iter
!=
client_metadata
.
end
())
{
iter
=
client_metadata
.
find
(
"user-agent"
);
if
(
iter
!=
client_metadata
.
end
())
{
context
->
AddInitialMetadata
(
kEchoUserAgentKey
,
iter
->
second
.
data
());
}
}
}
}
bool
SetPayload
(
PayloadType
type
,
int
size
,
Payload
*
payload
)
{
bool
SetPayload
(
PayloadType
type
,
int
size
,
Payload
*
payload
)
{
...
@@ -150,6 +160,7 @@ class TestServiceImpl : public TestService::Service {
...
@@ -150,6 +160,7 @@ class TestServiceImpl : public TestService::Service {
public:
public:
Status
EmptyCall
(
ServerContext
*
context
,
const
grpc
::
testing
::
Empty
*
request
,
Status
EmptyCall
(
ServerContext
*
context
,
const
grpc
::
testing
::
Empty
*
request
,
grpc
::
testing
::
Empty
*
response
)
{
grpc
::
testing
::
Empty
*
response
)
{
MaybeEchoMetadata
(
context
);
return
Status
::
OK
;
return
Status
::
OK
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment