This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 8239f6c8 fix normal h2 with gzip data (#2335)
8239f6c8 is described below
commit 8239f6c85c5d1f47315dd14a809d7b5d59eff35a
Author: Ran Miller <[email protected]>
AuthorDate: Wed Aug 2 19:19:16 2023 +0800
fix normal h2 with gzip data (#2335)
---
src/brpc/policy/http_rpc_protocol.cpp | 40 +++++++++++++++++------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/brpc/policy/http_rpc_protocol.cpp
b/src/brpc/policy/http_rpc_protocol.cpp
index 53ab6290..58e89ee0 100644
--- a/src/brpc/policy/http_rpc_protocol.cpp
+++ b/src/brpc/policy/http_rpc_protocol.cpp
@@ -1477,30 +1477,28 @@ void ProcessHttpRequest(InputMessageBase *msg) {
const HttpContentType content_type =
ParseContentType(req_header.content_type(), &is_grpc_ct);
const std::string* encoding = NULL;
- if (is_http2) {
- if (is_grpc_ct) {
- bool grpc_compressed = false;
- if (!RemoveGrpcPrefix(&req_body, &grpc_compressed)) {
- cntl->SetFailed(EREQUEST, "Invalid gRPC request");
+ if (is_http2 && is_grpc_ct) {
+ bool grpc_compressed = false;
+ if (!RemoveGrpcPrefix(&req_body, &grpc_compressed)) {
+ cntl->SetFailed(EREQUEST, "Invalid gRPC request");
+ return;
+ }
+ if (grpc_compressed) {
+ encoding = req_header.GetHeader(common->GRPC_ENCODING);
+ if (encoding == NULL) {
+ cntl->SetFailed(
+ EREQUEST, "Fail to find header `grpc-encoding'"
+ " in compressed gRPC request");
return;
}
- if (grpc_compressed) {
- encoding = req_header.GetHeader(common->GRPC_ENCODING);
- if (encoding == NULL) {
- cntl->SetFailed(
- EREQUEST, "Fail to find header `grpc-encoding'"
- " in compressed gRPC request");
- return;
- }
- }
- int64_t timeout_value_us =
-
ConvertGrpcTimeoutToUS(req_header.GetHeader(common->GRPC_TIMEOUT));
- if (timeout_value_us >= 0) {
- accessor.set_deadline_us(
- butil::gettimeofday_us() + timeout_value_us);
- }
}
- } else {
+ int64_t timeout_value_us =
+
ConvertGrpcTimeoutToUS(req_header.GetHeader(common->GRPC_TIMEOUT));
+ if (timeout_value_us >= 0) {
+ accessor.set_deadline_us(
+ butil::gettimeofday_us() + timeout_value_us);
+ }
+ } else { // http or h2 but not grpc
encoding = req_header.GetHeader(common->CONTENT_ENCODING);
}
if (encoding != NULL && *encoding == common->GZIP) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]