Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Unified Diff: components/safe_browsing_db/v4_protocol_manager_util.cc

Issue 2057433002: Replace the old URL format for PVer4 requests with the new format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback: nparker. GetRequestUrlAndUpdateHeaders -> GetRequestUrlAndHeaders Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing_db/v4_protocol_manager_util.cc
diff --git a/components/safe_browsing_db/v4_protocol_manager_util.cc b/components/safe_browsing_db/v4_protocol_manager_util.cc
index ec2de4cc6720c83db198845a552c65a227c69880..fde1c4aaaf6b710cdbcd8227a0df9a850e1c1b9b 100644
--- a/components/safe_browsing_db/v4_protocol_manager_util.cc
+++ b/components/safe_browsing_db/v4_protocol_manager_util.cc
@@ -9,6 +9,7 @@
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "net/base/escape.h"
+#include "net/http/http_request_headers.h"
using base::Time;
using base::TimeDelta;
@@ -77,29 +78,26 @@ void V4ProtocolManagerUtil::RecordHttpResponseOrErrorCode(
}
// static
-// The API hash call uses the pver4 Safe Browsing server.
-GURL V4ProtocolManagerUtil::GetRequestUrl(const std::string& request_base64,
- const std::string& method_name,
- const V4ProtocolConfig& config) {
- std::string url =
- ComposeUrl(kSbV4UrlPrefix, method_name, request_base64,
- config.client_name, config.version, config.key_param);
- return GURL(url);
+void V4ProtocolManagerUtil::GetRequestUrlAndHeaders(
+ const std::string& request_base64,
+ const std::string& method_name,
+ const V4ProtocolConfig& config,
+ GURL* gurl,
+ net::HttpRequestHeaders* headers) {
+ *gurl = GURL(ComposeUrl(kSbV4UrlPrefix, method_name, request_base64,
+ config.key_param));
+ UpdateHeaders(headers);
}
// static
std::string V4ProtocolManagerUtil::ComposeUrl(const std::string& prefix,
const std::string& method,
const std::string& request_base64,
- const std::string& client_id,
- const std::string& version,
const std::string& key_param) {
- DCHECK(!prefix.empty() && !method.empty() && !client_id.empty() &&
- !version.empty());
- std::string url =
- base::StringPrintf("%s/%s/%s?alt=proto&client_id=%s&client_version=%s",
- prefix.c_str(), method.c_str(), request_base64.c_str(),
- client_id.c_str(), version.c_str());
+ DCHECK(!prefix.empty() && !method.empty());
+ std::string url = base::StringPrintf(
+ "%s/%s?$req=%s&$ct=application/x-protobuf", prefix.c_str(),
+ method.c_str(), request_base64.c_str());
if (!key_param.empty()) {
base::StringAppendF(&url, "&key=%s",
net::EscapeQueryParamValue(key_param, true).c_str());
@@ -107,4 +105,12 @@ std::string V4ProtocolManagerUtil::ComposeUrl(const std::string& prefix,
return url;
}
+// static
+void V4ProtocolManagerUtil::UpdateHeaders(net::HttpRequestHeaders* headers) {
+ // NOTE(vakh): The following header informs the envelope server (which sits in
+ // front of Google's stubby server) that the received GET request should be
+ // interpreted as a POST.
+ headers->SetHeaderIfMissing("X-HTTP-Method-Override", "POST");
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698