Skip to content

Commit

Permalink
api to create encrypted header
Browse files Browse the repository at this point in the history
Summary:
## Context

- Design doc:
https://docs.google.com/document/d/1oAxFfQDJ2Ti3NH981jW-okfcrx4cPRo6N8FWKUp5WxM/edit#heading=h.g9v8c7dr6d6o
- Context: https://fb.workplace.com/groups/proxygendevelopers/posts/1033854548378587/?comment_id=1040393961057979

## This diff
- Create a `createProxyStatusEncrypted` function.
  - We'll call this function at multiple places in DFSRouter for 429/503 responses.
  - Next half, Traffic team plans to have a KR to make our proxy-status header library RFC compliant. We plan to modify this function like this:

```
ProxyStatusEncrypted createProxyStatusHeader(StatusType statusType, std::string& proxy, std::string& details) {
  if (use legacy format) {
    // Example result:
    // `Proxy-Status: http_request_error; e_proxy="dfsrouter"; details="DFSRouter RPS Throttling"`

  } else {
    // Example result:
    // `Proxy-Status: "dfsrouter"; error=http_request_error; details="DFSRouter RPS Throttling"`

  }
}
```
- Add the [standard field "details"](https://www.rfc-editor.org/rfc/rfc9209.html#section-2.1.5) to ProxyStatus class.

Reviewed By: mjsaltus

Differential Revision: D62532980

fbshipit-source-id: 078533998927eac01ca9ecc0264410bfd4b573d1
  • Loading branch information
Guangyu Liu authored and facebook-github-bot committed Sep 16, 2024
1 parent 71d7092 commit 4de8050
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions third-party/proxygen/src/proxygen/lib/http/ProxyStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ constexpr folly::StringPiece kIsProxyErrorParam{"e_isproxyerr"};
constexpr folly::StringPiece kIsClientErrorTrue{"e_isclienterr"};
constexpr folly::StringPiece kIsServerErrorTrue{"e_isservererr"};
constexpr folly::StringPiece kClientAddrParam{"e_clientaddr"};
constexpr folly::StringPiece kDetails{"details"};

} // namespace

Expand Down Expand Up @@ -83,6 +84,10 @@ ProxyStatus& ProxyStatus::setClientAddress(const std::string& clientAddr) {
return setProxyStatusParameter(kClientAddrParam, clientAddr);
}

ProxyStatus& ProxyStatus::setDetails(const std::string& details) {
return setProxyStatusParameter(kDetails, details);
}

bool ProxyStatus::hasUpstreamIP() const {
return pIdent_.parameterMap.find(std::string(kUpstreamIPParam)) !=
pIdent_.parameterMap.end();
Expand Down
1 change: 1 addition & 0 deletions third-party/proxygen/src/proxygen/lib/http/ProxyStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ProxyStatus {
ProxyStatus& setClientError(const bool isProxyError);
ProxyStatus& setServerError(const bool isProxyError);
ProxyStatus& setClientAddress(const std::string& clientAddr);
ProxyStatus& setDetails(const std::string& details);
virtual ProxyStatus& setProxyStatusParameter(folly::StringPiece name,
const std::string& text);

Expand Down

0 comments on commit 4de8050

Please sign in to comment.