No public description

PiperOrigin-RevId: 864907243
diff --git a/quiche/quic/masque/masque_ohttp_client.cc b/quiche/quic/masque/masque_ohttp_client.cc
index 75b0740..b326cdb 100644
--- a/quiche/quic/masque/masque_ohttp_client.cc
+++ b/quiche/quic/masque/masque_ohttp_client.cc
@@ -478,7 +478,15 @@
   }
   auto cleanup =
       absl::MakeCleanup([this, it]() { pending_ohttp_requests_.erase(it); });
-  QUICHE_RETURN_IF_ERROR(response.status());
+  if (!response.ok()) {
+    if (it->second.per_request_config.expected_gateway_error().has_value() &&
+        absl::StrContains(
+            response.status().message(),
+            *it->second.per_request_config.expected_gateway_error())) {
+      return absl::OkStatus();
+    }
+    return response.status();
+  }
   int16_t gateway_status_code = MasqueConnectionPool::GetStatusCode(*response);
   if (it->second.per_request_config.expected_gateway_status_code()
           .has_value()) {
diff --git a/quiche/quic/masque/masque_ohttp_client.h b/quiche/quic/masque/masque_ohttp_client.h
index 988efaa..6d188ff 100644
--- a/quiche/quic/masque/masque_ohttp_client.h
+++ b/quiche/quic/masque/masque_ohttp_client.h
@@ -49,6 +49,9 @@
       void SetUseChunkedOhttp(bool use_chunked_ohttp) {
         use_chunked_ohttp_ = use_chunked_ohttp;
       }
+      void SetExpectedGatewayError(const std::string& expected_gateway_error) {
+        expected_gateway_error_ = expected_gateway_error;
+      }
       void SetExpectedGatewayStatusCode(uint16_t status_code) {
         expected_gateway_status_code_ = status_code;
       }
@@ -68,6 +71,9 @@
       std::string post_data() const { return post_data_; }
       std::string private_token() const { return private_token_; }
       bool use_chunked_ohttp() const { return use_chunked_ohttp_; }
+      std::optional<std::string> expected_gateway_error() const {
+        return expected_gateway_error_;
+      }
       std::optional<uint16_t> expected_gateway_status_code() const {
         return expected_gateway_status_code_;
       }
@@ -83,6 +89,7 @@
       std::string post_data_;
       std::string private_token_;
       bool use_chunked_ohttp_ = false;
+      std::optional<std::string> expected_gateway_error_;
       std::optional<uint16_t> expected_gateway_status_code_;
       std::optional<uint16_t> expected_encapsulated_status_code_;
       std::optional<std::string> expected_encapsulated_response_body_;
diff --git a/quiche/quic/masque/masque_ohttp_client_bin.cc b/quiche/quic/masque/masque_ohttp_client_bin.cc
index 1fcf9f3..8b6e78d 100644
--- a/quiche/quic/masque/masque_ohttp_client_bin.cc
+++ b/quiche/quic/masque/masque_ohttp_client_bin.cc
@@ -57,6 +57,11 @@
     "port. PORT2 can be empty to not override ports. Multiple overrides can be "
     "specified separated by semi-colons.");
 
+DEFINE_QUICHE_COMMAND_LINE_FLAG(std::optional<std::string>,
+                                expect_gateway_error, std::nullopt,
+                                "If set, the client will expect this text in "
+                                "the error message for the gateway response.");
+
 DEFINE_QUICHE_COMMAND_LINE_FLAG(
     std::optional<int16_t>, expect_gateway_response_code, std::nullopt,
     "If set, the client will expect this response code from the gateway.");
@@ -79,6 +84,8 @@
       quiche::GetQuicheCommandLineFlag(FLAGS_client_cert_file);
   const std::string client_cert_key_file =
       quiche::GetQuicheCommandLineFlag(FLAGS_client_cert_key_file);
+  const std::optional<std::string> expect_gateway_error =
+      quiche::GetQuicheCommandLineFlag(FLAGS_expect_gateway_error);
   const std::optional<int16_t> expect_gateway_response_code =
       quiche::GetQuicheCommandLineFlag(FLAGS_expect_gateway_response_code);
 
@@ -109,6 +116,9 @@
     per_request_config.SetPostData(post_data);
     per_request_config.SetUseChunkedOhttp(use_chunked_ohttp);
     per_request_config.SetPrivateToken(private_token);
+    if (expect_gateway_error.has_value()) {
+      per_request_config.SetExpectedGatewayError(*expect_gateway_error);
+    }
     if (expect_gateway_response_code.has_value()) {
       per_request_config.SetExpectedGatewayStatusCode(
           *expect_gateway_response_code);