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>2019-10-15 17:54:19 +0300
committermpimenov <mpimenov@users.noreply.github.com>2019-10-16 12:57:42 +0300
commitbe9980781292eb443efeac567225d9a723d19cf6 (patch)
tree9d1e887267821069ddfb742662be30c6bccbe33e /web_api
parentfa59f1907c139cfa67ff0b982dca3165103de6d7 (diff)
Added device id header to catalog requests
Diffstat (limited to 'web_api')
-rw-r--r--web_api/CMakeLists.txt11
-rw-r--r--web_api/request_headers.cpp17
-rw-r--r--web_api/request_headers.hpp11
-rw-r--r--web_api/utils.cpp13
-rw-r--r--web_api/utils.hpp8
5 files changed, 60 insertions, 0 deletions
diff --git a/web_api/CMakeLists.txt b/web_api/CMakeLists.txt
new file mode 100644
index 0000000000..793002f8a9
--- /dev/null
+++ b/web_api/CMakeLists.txt
@@ -0,0 +1,11 @@
+project(web_api)
+
+set(
+ SRC
+ request_headers.cpp
+ request_headers.hpp
+ utils.cpp
+ utils.hpp
+)
+
+omim_add_library(${PROJECT_NAME} ${SRC})
diff --git a/web_api/request_headers.cpp b/web_api/request_headers.cpp
new file mode 100644
index 0000000000..929ceea3ea
--- /dev/null
+++ b/web_api/request_headers.cpp
@@ -0,0 +1,17 @@
+#include "web_api/request_headers.hpp"
+
+#include "web_api/utils.hpp"
+
+#include "platform/platform.hpp"
+
+namespace web_api
+{
+char const * const kDeviceIdHeader = "X-Mapsme-Device-Id";
+char const * const kUserAgentHeader = "User-Agent";
+
+platform::HttpClient::Headers GetDefaultCatalogHeaders()
+{
+ return {{kUserAgentHeader, GetPlatform().GetAppUserAgent()},
+ {kDeviceIdHeader, DeviceId()}};
+}
+} // namespace web_api
diff --git a/web_api/request_headers.hpp b/web_api/request_headers.hpp
new file mode 100644
index 0000000000..0c0146a577
--- /dev/null
+++ b/web_api/request_headers.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "platform/http_client.hpp"
+
+namespace web_api
+{
+extern char const * const kDeviceIdHeader;
+extern char const * const kUserAgentHeader;
+
+platform::HttpClient::Headers GetDefaultCatalogHeaders();
+} // namespace web_api
diff --git a/web_api/utils.cpp b/web_api/utils.cpp
new file mode 100644
index 0000000000..504398095c
--- /dev/null
+++ b/web_api/utils.cpp
@@ -0,0 +1,13 @@
+#include "web_api/utils.hpp"
+
+#include "platform/platform.hpp"
+
+#include "coding/sha1.hpp"
+
+namespace web_api
+{
+std::string DeviceId()
+{
+ return coding::SHA1::CalculateBase64ForString(GetPlatform().UniqueClientId());
+}
+} // namespace web_api
diff --git a/web_api/utils.hpp b/web_api/utils.hpp
new file mode 100644
index 0000000000..3895964397
--- /dev/null
+++ b/web_api/utils.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+#include <string>
+
+namespace web_api
+{
+std::string DeviceId();
+} // namespace web_api