You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ww...@apache.org on 2023/04/28 01:48:25 UTC

[brpc] branch master updated: Add http error code doc (#2224)

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 a0a79378 Add http error code doc (#2224)
a0a79378 is described below

commit a0a79378d93f60c3d0610124120e85aeac900a21
Author: Bright Chen <ch...@foxmail.com>
AuthorDate: Fri Apr 28 09:48:13 2023 +0800

    Add http error code doc (#2224)
---
 docs/cn/http_client.md | 2 ++
 docs/en/http_client.md | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/docs/cn/http_client.md b/docs/cn/http_client.md
index b34b0618..f5fea9f3 100644
--- a/docs/cn/http_client.md
+++ b/docs/cn/http_client.md
@@ -179,6 +179,8 @@ Notes on http header:
 
 当Server返回的http status code不是2xx时,该次http/h2访问被视为失败,client端会把`cntl->ErrorCode()`设置为EHTTP,用户可通过`cntl->http_response().status_code()`获得具体的http错误。同时server端可以把代表错误的html或json置入`cntl->response_attachment()`作为http body传递回来。
 
+如果Server也是brpc框架实现的服务,client端希望在http/h2失败时获取brpc Server返回的真实`ErrorCode`,而不是统一设置的`EHTTP`,则需要设置GFlag`-use_http_error_code=true`。
+
 # 压缩request body
 
 调用Controller::set_request_compress_type(brpc::COMPRESS_TYPE_GZIP)将尝试用gzip压缩http body。
diff --git a/docs/en/http_client.md b/docs/en/http_client.md
index a7cf5205..6c64431c 100644
--- a/docs/en/http_client.md
+++ b/docs/en/http_client.md
@@ -186,6 +186,8 @@ Turn on [-http_verbose](http://brpc.baidu.com:8765/flags/http_verbose) so that t
 
 When server returns a non-2xx HTTP status code, the HTTP RPC is considered to be failed and `cntl->ErrorCode()` at client-side is set to `EHTTP`, users can check `cntl-> http_response().status_code()` for more specific HTTP error. In addition, server can put html or json describing the error into `cntl->response_attachment()` which is sent back to the client as http body.
 
+If client-side wants to get the real `ErrorCode` returned by the bRPC server when the HTTP RPC fails, instead of `EHTTP`, you need to set GFlag`-use_http_error_code=true`.
+
 # Compress Request Body
 
 `Controller::set_request_compress_type(brpc::COMPRESS_TYPE_GZIP)` makes framework try to gzip the HTTP body. "try to" means the compression may not happen, because:


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org