Skip to content

Commit

Permalink
[ads] HTTP status code health
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey committed Sep 11, 2024
1 parent ee16ff5 commit 136347c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "brave/components/brave_ads/core/internal/ads_client/ads_client_util.h"
#include "brave/components/brave_ads/core/internal/ads_notifier_manager.h"
#include "brave/components/brave_ads/core/internal/common/logging_util.h"
#include "brave/components/brave_ads/core/internal/common/net/http/http_status_code.h"
#include "brave/components/brave_ads/core/internal/common/time/time_formatting_util.h"
#include "brave/components/brave_ads/core/internal/common/url/url_request_string_util.h"
#include "brave/components/brave_ads/core/internal/common/url/url_response_string_util.h"
Expand Down Expand Up @@ -79,7 +78,7 @@ void IssuersUrlRequest::FetchCallback(

is_fetching_ = false;

if (mojom_url_response.status_code == net::kHttpUpgradeRequired) {
if (mojom_url_response.status_code == net::HTTP_UPGRADE_REQUIRED) {
BLOG(1, "Failed to fetch issuers as a browser upgrade is required");

return AdsNotifierManager::GetInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "brave/components/brave_ads/core/internal/ads_notifier_manager.h"
#include "brave/components/brave_ads/core/internal/common/challenge_bypass_ristretto/blinded_token_util.h"
#include "brave/components/brave_ads/core/internal/common/logging_util.h"
#include "brave/components/brave_ads/core/internal/common/net/http/http_status_code.h"
#include "brave/components/brave_ads/core/internal/common/url/url_request_string_util.h"
#include "brave/components/brave_ads/core/internal/common/url/url_response_string_util.h"
#include "brave/components/brave_ads/core/mojom/brave_ads.mojom.h"
Expand Down Expand Up @@ -135,7 +134,7 @@ void RefillConfirmationTokens::RequestSignedTokensCallback(
base::expected<void, std::tuple<std::string, bool>>
RefillConfirmationTokens::HandleRequestSignedTokensUrlResponse(
const mojom::UrlResponseInfo& mojom_url_response) {
if (mojom_url_response.status_code == net::kHttpUpgradeRequired) {
if (mojom_url_response.status_code == net::HTTP_UPGRADE_REQUIRED) {
AdsNotifierManager::GetInstance().NotifyBrowserUpgradeRequiredToServeAds();

return base::unexpected(std::make_tuple(
Expand Down Expand Up @@ -209,7 +208,7 @@ RefillConfirmationTokens::HandleGetSignedTokensUrlResponse(
CHECK(tokens_);
CHECK(blinded_tokens_);

if (mojom_url_response.status_code == net::kHttpUpgradeRequired) {
if (mojom_url_response.status_code == net::HTTP_UPGRADE_REQUIRED) {
AdsNotifierManager::GetInstance().NotifyBrowserUpgradeRequiredToServeAds();

return base::unexpected(std::make_tuple(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "brave/components/brave_ads/core/internal/catalog/catalog_url_request_json_reader.h"
#include "brave/components/brave_ads/core/internal/catalog/catalog_util.h"
#include "brave/components/brave_ads/core/internal/common/logging_util.h"
#include "brave/components/brave_ads/core/internal/common/net/http/http_status_code.h"
#include "brave/components/brave_ads/core/internal/common/time/time_formatting_util.h"
#include "brave/components/brave_ads/core/internal/common/url/url_request_string_util.h"
#include "brave/components/brave_ads/core/internal/common/url/url_response_string_util.h"
Expand Down Expand Up @@ -81,7 +80,7 @@ void CatalogUrlRequest::FetchCallback(

is_fetching_ = false;

if (mojom_url_response.status_code == net::kHttpUpgradeRequired) {
if (mojom_url_response.status_code == net::HTTP_UPGRADE_REQUIRED) {
BLOG(1, "Failed to request catalog as a browser upgrade is required");
return AdsNotifierManager::GetInstance()
.NotifyBrowserUpgradeRequiredToServeAds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

namespace net {

// HTTP status code 418 "I'm a teapot" is an April Fools' joke from the IETF's
// RFC 2324, Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0).
constexpr int kHttpImATeapot = 418;
constexpr int kHttpUpgradeRequired = 426;

} // namespace net

Expand Down

0 comments on commit 136347c

Please sign in to comment.