Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2018-07-31 21:09:14 +0300
committerAleksey Belousov <beloal@users.noreply.github.com>2018-08-10 20:16:14 +0300
commit9a8c58ee092ee108f5b360c55fdce34611221d11 (patch)
treef179dd216be5553bb7d5f28e0b9a453e744de4c3 /platform
parent98729c07f710b5b088307dc197e00f6f6569a0fb (diff)
Review fixes
Diffstat (limited to 'platform')
-rw-r--r--platform/http_client.cpp5
-rw-r--r--platform/http_client.hpp3
-rw-r--r--platform/http_user_agent.cpp7
-rw-r--r--platform/http_user_agent.hpp5
-rw-r--r--platform/platform.hpp1
-rw-r--r--platform/remote_file.cpp2
6 files changed, 6 insertions, 17 deletions
diff --git a/platform/http_client.cpp b/platform/http_client.cpp
index 4561eeb5f9..a7b3a03641 100644
--- a/platform/http_client.cpp
+++ b/platform/http_client.cpp
@@ -95,11 +95,6 @@ void HttpClient::SetTimeout(double timeoutSec)
m_timeoutSec = timeoutSec;
}
-void HttpClient::SetUserAgent(HttpUserAgent const & userAgent)
-{
- m_headers.emplace(userAgent.Key(), userAgent.Value());
-}
-
string const & HttpClient::UrlRequested() const
{
return m_urlRequested;
diff --git a/platform/http_client.hpp b/platform/http_client.hpp
index 7273f37753..37f6096d90 100644
--- a/platform/http_client.hpp
+++ b/platform/http_client.hpp
@@ -23,8 +23,6 @@ SOFTWARE.
*******************************************************************************/
#pragma once
-#include "platform/http_user_agent.hpp"
-
#include "base/macros.hpp"
#include "std/string.hpp"
@@ -85,7 +83,6 @@ public:
HttpClient & SetHandleRedirects(bool handle_redirects);
HttpClient & SetRawHeader(string const & key, string const & value);
void SetTimeout(double timeoutSec);
- void SetUserAgent(HttpUserAgent const & userAgent);
string const & UrlRequested() const;
// @returns empty string in the case of error
diff --git a/platform/http_user_agent.cpp b/platform/http_user_agent.cpp
index c3651a6f5c..304df85d06 100644
--- a/platform/http_user_agent.cpp
+++ b/platform/http_user_agent.cpp
@@ -9,12 +9,7 @@ HttpUserAgent::HttpUserAgent()
m_appVersion = ExtractAppVersion();
}
-std::string HttpUserAgent::Key() const
-{
- return "User-Agent";
-}
-
-std::string HttpUserAgent::Value() const
+std::string HttpUserAgent::Get() const
{
std::stringstream ss;
ss << "MAPS.ME/";
diff --git a/platform/http_user_agent.hpp b/platform/http_user_agent.hpp
index 842bd98b1b..8636edcc0b 100644
--- a/platform/http_user_agent.hpp
+++ b/platform/http_user_agent.hpp
@@ -8,8 +8,9 @@ class HttpUserAgent
{
public:
HttpUserAgent();
- std::string Key() const;
- std::string Value() const;
+ std::string Get() const;
+
+ operator std::string() const { return Get(); }
private:
std::string ExtractAppVersion() const;
diff --git a/platform/platform.hpp b/platform/platform.hpp
index 47aa3b9906..56d81818fd 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -284,6 +284,7 @@ public:
MarketingService & GetMarketingService() { return m_marketingService; }
platform::SecureStorage & GetSecureStorage() { return m_secureStorage; }
platform::HttpUserAgent & GetAppUserAgent() { return m_appUserAgent; }
+ platform::HttpUserAgent const & GetAppUserAgent() const { return m_appUserAgent; }
/// \brief Placing an executable object |task| on a queue of |thread|. Then the object will be
/// executed on |thread|.
diff --git a/platform/remote_file.cpp b/platform/remote_file.cpp
index 961917af25..a79a3ecdf1 100644
--- a/platform/remote_file.cpp
+++ b/platform/remote_file.cpp
@@ -26,7 +26,7 @@ RemoteFile::Result RemoteFile::Download(std::string const & filePath) const
platform::HttpClient request(m_url);
request.SetTimeout(kRequestTimeoutInSec);
- request.SetUserAgent(GetPlatform().GetAppUserAgent());
+ request.SetRawHeader("User-Agent", GetPlatform().GetAppUserAgent());
if (request.RunHttpRequest())
{
if (!m_allowRedirection && request.WasRedirected())