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
b94656d2
Commit
b94656d2
authored
8 years ago
by
Makarand Dharmapurikar
Browse files
Options
Downloads
Patches
Plain Diff
addressed review feedback.
moved method computation in a if block only when send_initial_metadata is true.
parent
432d1db1
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
src/core/lib/channel/http_client_filter.c
+48
-48
48 additions, 48 deletions
src/core/lib/channel/http_client_filter.c
with
48 additions
and
48 deletions
src/core/lib/channel/http_client_filter.c
+
48
−
48
View file @
b94656d2
...
@@ -208,57 +208,57 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
...
@@ -208,57 +208,57 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
call_data
*
calld
=
elem
->
call_data
;
call_data
*
calld
=
elem
->
call_data
;
channel_data
*
channeld
=
elem
->
channel_data
;
channel_data
*
channeld
=
elem
->
channel_data
;
/* Decide which HTTP VERB to use. We use GET if the request is marked
if
(
op
->
send_initial_metadata
!=
NULL
)
{
cacheable, and the operation contains both initial metadata and send message,
/* Decide which HTTP VERB to use. We use GET if the request is marked
and the payload is below the size threshold, and all the data
cacheable, and the operation contains both initial metadata and send
for this request is immediately available. */
message, and the payload is below the size threshold, and all the data
grpc_mdelem
*
method
=
GRPC_MDELEM_METHOD_POST
;
for this request is immediately available. */
calld
->
send_message_blocked
=
false
;
grpc_mdelem
*
method
=
GRPC_MDELEM_METHOD_POST
;
if
(
op
->
send_initial_metadata
!=
NULL
&&
calld
->
send_message_blocked
=
false
;
(
op
->
send_initial_metadata_flags
&
if
((
op
->
send_initial_metadata_flags
&
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST
)
&&
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST
)
&&
op
->
send_message
!=
NULL
&&
op
->
send_message
!=
NULL
&&
op
->
send_message
->
length
<
channeld
->
max_payload_size_for_get
)
{
op
->
send_message
->
length
<
channeld
->
max_payload_size_for_get
)
{
method
=
GRPC_MDELEM_METHOD_GET
;
method
=
GRPC_MDELEM_METHOD_GET
;
calld
->
send_message_blocked
=
true
;
calld
->
send_message_blocked
=
true
;
}
else
if
(
op
->
send_initial_metadata_flags
&
}
else
if
(
op
->
send_initial_metadata_flags
&
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST
)
{
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST
)
{
method
=
GRPC_MDELEM_METHOD_PUT
;
method
=
GRPC_MDELEM_METHOD_PUT
;
}
}
/* Attempt to read the data from send_message and create a header field. */
if
(
method
==
GRPC_MDELEM_METHOD_GET
)
{
/* allocate memory to hold the entire payload */
calld
->
payload_bytes
=
gpr_malloc
(
op
->
send_message
->
length
);
GPR_ASSERT
(
calld
->
payload_bytes
);
/* read slices of send_message and copy into payload_bytes */
calld
->
send_op
=
*
op
;
calld
->
send_length
=
op
->
send_message
->
length
;
calld
->
send_flags
=
op
->
send_message
->
flags
;
continue_send_message
(
exec_ctx
,
elem
);
if
(
calld
->
send_message_blocked
==
false
)
{
/* Attempt to read the data from send_message and create a header field. */
/* when all the send_message data is available, then create a MDELEM and
if
(
method
==
GRPC_MDELEM_METHOD_GET
)
{
append to headers */
/* allocate memory to hold the entire payload */
grpc_mdelem
*
payload_bin
=
grpc_mdelem_from_metadata_strings
(
calld
->
payload_bytes
=
gpr_malloc
(
op
->
send_message
->
length
);
GRPC_MDSTR_GRPC_PAYLOAD_BIN
,
GPR_ASSERT
(
calld
->
payload_bytes
);
grpc_mdstr_from_buffer
(
calld
->
payload_bytes
,
op
->
send_message
->
length
));
/* read slices of send_message and copy into payload_bytes */
grpc_metadata_batch_add_tail
(
op
->
send_initial_metadata
,
calld
->
send_op
=
*
op
;
&
calld
->
payload_bin
,
payload_bin
);
calld
->
send_length
=
op
->
send_message
->
length
;
calld
->
on_complete
=
op
->
on_complete
;
calld
->
send_flags
=
op
->
send_message
->
flags
;
op
->
on_complete
=
&
calld
->
hc_on_complete
;
continue_send_message
(
exec_ctx
,
elem
);
op
->
send_message
=
NULL
;
}
else
{
if
(
calld
->
send_message_blocked
==
false
)
{
/* Not all data is available. Fall back to POST. */
/* when all the send_message data is available, then create a MDELEM and
gpr_log
(
GPR_DEBUG
,
append to headers */
"Request is marked Cacheable but not all data is available.\
grpc_mdelem
*
payload_bin
=
grpc_mdelem_from_metadata_strings
(
Falling back to POST"
);
GRPC_MDSTR_GRPC_PAYLOAD_BIN
,
method
=
GRPC_MDELEM_METHOD_POST
;
grpc_mdstr_from_buffer
(
calld
->
payload_bytes
,
op
->
send_message
->
length
));
grpc_metadata_batch_add_tail
(
op
->
send_initial_metadata
,
&
calld
->
payload_bin
,
payload_bin
);
calld
->
on_complete
=
op
->
on_complete
;
op
->
on_complete
=
&
calld
->
hc_on_complete
;
op
->
send_message
=
NULL
;
}
else
{
/* Not all data is available. Fall back to POST. */
gpr_log
(
GPR_DEBUG
,
"Request is marked Cacheable but not all data is available.\
Falling back to POST"
);
method
=
GRPC_MDELEM_METHOD_POST
;
}
}
}
}
if
(
op
->
send_initial_metadata
!=
NULL
)
{
grpc_metadata_batch_filter
(
op
->
send_initial_metadata
,
client_strip_filter
,
grpc_metadata_batch_filter
(
op
->
send_initial_metadata
,
client_strip_filter
,
elem
);
elem
);
/* Send : prefixed headers, which have to be before any application
/* Send : prefixed headers, which have to be before any application
...
...
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