Skip to content

Commit

Permalink
Add http error code doc (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenBright authored Apr 28, 2023
1 parent ec11bb3 commit a0a7937
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/cn/http_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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。
Expand Down
2 changes: 2 additions & 0 deletions docs/en/http_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a0a7937

Please sign in to comment.