Chromium Code Reviews| 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..2be77a8c962a0bcba101e1bab3731fbff23c7931 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,25 @@ 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); |
| +GURL V4ProtocolManagerUtil::GetRequestUrlAndUpdateHeaders( |
| + const std::string& request_base64, |
| + const std::string& method_name, |
| + const V4ProtocolConfig& config, |
| + net::HttpRequestHeaders* headers) { |
| + UpdateHeaders(headers); |
| + return GURL(ComposeUrl(kSbV4UrlPrefix, method_name, request_base64, |
| + config.key_param)); |
| } |
| // 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 +104,9 @@ std::string V4ProtocolManagerUtil::ComposeUrl(const std::string& prefix, |
| return url; |
| } |
| +// static |
| +void V4ProtocolManagerUtil::UpdateHeaders(net::HttpRequestHeaders* headers) { |
| + headers->SetHeaderIfMissing("X-HTTP-Method-Override", "POST"); |
|
Nathan Parker
2016/06/09 20:22:18
If we get an explanation for this, we should add i
vakh (use Gerrit instead)
2016/06/09 21:02:15
Done.
|
| +} |
| + |
| } // namespace safe_browsing |