chore: use HTTP status code constants (#29378)

This commit is contained in:
David Sanders 2021-05-31 18:47:53 -07:00 committed by GitHub
parent ba26580f23
commit 0208e4adad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -101,7 +101,7 @@ network::mojom::URLResponseHeadPtr ToResponseHead(
return head; return head;
} }
int status_code = 200; int status_code = net::HTTP_OK;
dict.Get("statusCode", &status_code); dict.Get("statusCode", &status_code);
head->headers = new net::HttpResponseHeaders(base::StringPrintf( head->headers = new net::HttpResponseHeaders(base::StringPrintf(
"HTTP/1.1 %d %s", status_code, "HTTP/1.1 %d %s", status_code,

View file

@ -14,6 +14,7 @@
#include "extensions/browser/extension_navigation_ui_data.h" #include "extensions/browser/extension_navigation_ui_data.h"
#include "net/base/completion_repeating_callback.h" #include "net/base/completion_repeating_callback.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
@ -662,7 +663,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::
header_client_receiver_.reset(); header_client_receiver_.reset();
target_loader_.reset(); target_loader_.reset();
constexpr int kInternalRedirectStatusCode = 307; constexpr int kInternalRedirectStatusCode = net::HTTP_TEMPORARY_REDIRECT;
net::RedirectInfo redirect_info; net::RedirectInfo redirect_info;
redirect_info.status_code = kInternalRedirectStatusCode; redirect_info.status_code = kInternalRedirectStatusCode;

View file

@ -38,6 +38,7 @@
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "ipc/ipc_channel.h" #include "ipc/ipc_channel.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h" #include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
@ -289,7 +290,7 @@ class InspectableWebContents::NetworkResourceLoader
base::DictionaryValue response; base::DictionaryValue response;
response.SetInteger("statusCode", response_headers_ response.SetInteger("statusCode", response_headers_
? response_headers_->response_code() ? response_headers_->response_code()
: 200); : net::HTTP_OK);
auto headers = std::make_unique<base::DictionaryValue>(); auto headers = std::make_unique<base::DictionaryValue>();
size_t iterator = 0; size_t iterator = 0;
@ -652,7 +653,7 @@ void InspectableWebContents::LoadNetworkResource(DispatchCallback callback,
GURL gurl(url); GURL gurl(url);
if (!gurl.is_valid()) { if (!gurl.is_valid()) {
base::DictionaryValue response; base::DictionaryValue response;
response.SetInteger("statusCode", 404); response.SetInteger("statusCode", net::HTTP_NOT_FOUND);
std::move(callback).Run(&response); std::move(callback).Run(&response);
return; return;
} }