Merge lp:~stolowski/unity-scopes-api/user-agent into lp:unity-scopes-api/devel

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michi Henning
Approved revision: 261
Merged at revision: 495
Proposed branch: lp:~stolowski/unity-scopes-api/user-agent
Merge into: lp:unity-scopes-api/devel
Prerequisite: lp:~michihenning/unity-scopes-api/fix-amd64-symbol
Diff against target: 383 lines (+113/-17)
11 files modified
STRUCTS (+19/-0)
include/unity/scopes/internal/smartscopes/HttpClientInterface.h (+6/-1)
include/unity/scopes/internal/smartscopes/HttpClientQt.h (+4/-2)
include/unity/scopes/internal/smartscopes/HttpClientQtThread.h (+4/-1)
include/unity/scopes/internal/smartscopes/SmartScopesClient.h (+3/-1)
src/scopes/internal/smartscopes/HttpClientQt.cpp (+7/-5)
src/scopes/internal/smartscopes/HttpClientQtThread.cpp (+6/-1)
src/scopes/internal/smartscopes/SmartScope.cpp (+16/-3)
src/scopes/internal/smartscopes/SmartScopesClient.cpp (+18/-2)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py (+3/-0)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp (+27/-1)
To merge this branch: bzr merge lp:~stolowski/unity-scopes-api/user-agent
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michi Henning (community) Approve
Pete Woods Pending
Review via email: mp+235913@code.launchpad.net

This proposal supersedes a proposal from 2014-09-24.

Commit message

Pass User-Agent http header to SSS if recieved with SearchMetadata or PreviewMetadata.

Description of the change

Pass User-Agent http header to SSS if recieved with SearchMetadata or PreviewMetadata.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
Pete Woods (pete-woods) wrote : Posted in a previous version of this proposal

Apart from the symbols file stuff. This could be another example of the compiler producing amd64-only symbols.

i.e. (c++|arch=amd64) should be used as the symbol tag

Revision history for this message
Michi Henning (michihenning) wrote : Posted in a previous version of this proposal

BIG problem here: there is a redundant semicolon ;-)

247 - }
248 + };

I think the user-agent attribute should be documented in the STRUCTS file?

Other than that, this looks good!

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote : Posted in a previous version of this proposal

> BIG problem here: there is a redundant semicolon ;-)
>
> 247 - }
> 248 + };
>
> I think the user-agent attribute should be documented in the STRUCTS file?
>

Right, I noticed we were missing descriptions of the 3 *metadata structures that. I fixed that, however this particular value as well as e.g. session-id are transported using general hints container, and we don't really care what's there in the API, so these are not documented.

Revision history for this message
Paweł Stołowski (stolowski) wrote : Posted in a previous version of this proposal

I've merged Michi's symbols fix into this branch and am trying to resubmit it with new prerequisite branch, but LP gives me OOPses all the time. Setting to WIP till it succeeds.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Ok, it finally worked, it;s ready for review again.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Looking good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'STRUCTS'
--- STRUCTS 2014-06-26 05:59:38 +0000
+++ STRUCTS 2014-09-25 08:50:05 +0000
@@ -154,3 +154,22 @@
154============================================154============================================
155 'status' : int (corresponds to ActivationResponse::Status enum)155 'status' : int (corresponds to ActivationResponse::Status enum)
156 'scope_data' : variant156 'scope_data' : variant
157
158QueryMetadata (returned by serialize())
159=======================================
160 'type' : string (metadata type)
161 'locale' : string
162 'form_factor' : string
163 'hints' : dict
164 'internet_connectivity' : bool (optional)
165
166SearchMetadata (returned by serialize())
167========================================
168 all QueryMetadata attributes
169 'cardinality' : int
170 'location' : dict
171
172ActionMetadata (returned by serialize())
173========================================
174 all QueryMetadata attributes
175 'scope_data' : variant
157176
=== modified file 'include/unity/scopes/internal/smartscopes/HttpClientInterface.h'
--- include/unity/scopes/internal/smartscopes/HttpClientInterface.h 2014-08-28 15:27:19 +0000
+++ include/unity/scopes/internal/smartscopes/HttpClientInterface.h 2014-09-25 08:50:05 +0000
@@ -25,6 +25,8 @@
25#include <future>25#include <future>
26#include <string>26#include <string>
27#include <functional>27#include <functional>
28#include <list>
29#include <tuple>
2830
29namespace unity31namespace unity
30{32{
@@ -40,6 +42,8 @@
4042
41class HttpResponseHandle;43class HttpResponseHandle;
4244
45typedef std::list<std::pair<std::string, std::string>> HttpHeaders;
46
43class HttpClientInterface : public std::enable_shared_from_this<HttpClientInterface>47class HttpClientInterface : public std::enable_shared_from_this<HttpClientInterface>
44{48{
45public:49public:
@@ -50,7 +54,8 @@
50 virtual ~HttpClientInterface() = default;54 virtual ~HttpClientInterface() = default;
5155
52 virtual std::shared_ptr<HttpResponseHandle> get(std::string const& request_url,56 virtual std::shared_ptr<HttpResponseHandle> get(std::string const& request_url,
53 std::function<void(std::string const&)> const& lineData = [](std::string const&) {}) = 0;57 std::function<void(std::string const&)> const& lineData = [](std::string const&) {},
58 HttpHeaders const& headers = HttpHeaders()) = 0;
5459
55 virtual std::string to_percent_encoding(std::string const& string) = 0;60 virtual std::string to_percent_encoding(std::string const& string) = 0;
5661
5762
=== modified file 'include/unity/scopes/internal/smartscopes/HttpClientQt.h'
--- include/unity/scopes/internal/smartscopes/HttpClientQt.h 2014-09-02 11:58:04 +0000
+++ include/unity/scopes/internal/smartscopes/HttpClientQt.h 2014-09-25 08:50:05 +0000
@@ -44,7 +44,8 @@
44 explicit HttpClientQt(unsigned int no_reply_timeout);44 explicit HttpClientQt(unsigned int no_reply_timeout);
45 ~HttpClientQt();45 ~HttpClientQt();
4646
47 HttpResponseHandle::SPtr get(std::string const& request_url, std::function<void(std::string const&)> const& lineData = [](std::string const&) {}) override;47 HttpResponseHandle::SPtr get(std::string const& request_url, std::function<void(std::string const&)> const& lineData = [](std::string const&) {},
48 HttpHeaders const& headers = HttpHeaders()) override;
4849
49 std::string to_percent_encoding(std::string const& string) override;50 std::string to_percent_encoding(std::string const& string) override;
5051
@@ -55,7 +56,8 @@
55 class HttpSession56 class HttpSession
56 {57 {
57 public:58 public:
58 HttpSession(std::string const& request_url, unsigned int timeout, std::function<void(std::string const&)> const& lineData);59 HttpSession(std::string const& request_url, unsigned int timeout, std::function<void(std::string const&)> const& lineData, HttpHeaders const& headers =
60 HttpHeaders());
59 ~HttpSession();61 ~HttpSession();
6062
61 std::future<void> get_future();63 std::future<void> get_future();
6264
=== modified file 'include/unity/scopes/internal/smartscopes/HttpClientQtThread.h'
--- include/unity/scopes/internal/smartscopes/HttpClientQtThread.h 2014-08-26 12:17:18 +0000
+++ include/unity/scopes/internal/smartscopes/HttpClientQtThread.h 2014-09-25 08:50:05 +0000
@@ -36,6 +36,7 @@
36 #include <QUrl>36 #include <QUrl>
37#endif37#endif
3838
39#include <unity/scopes/internal/smartscopes/HttpClientInterface.h>
39#include <unity/util/NonCopyable.h>40#include <unity/util/NonCopyable.h>
4041
41#include <mutex>42#include <mutex>
@@ -62,7 +63,8 @@
62public:63public:
63 NONCOPYABLE(HttpClientQtThread);64 NONCOPYABLE(HttpClientQtThread);
6465
65 HttpClientQtThread(const QUrl& url, unsigned int timeout, std::function<void(std::string const&)> const& lineData);66 HttpClientQtThread(const QUrl& url, unsigned int timeout, std::function<void(std::string const&)> const& lineData, const HttpHeaders& headers =
67 HttpHeaders());
66 ~HttpClientQtThread();68 ~HttpClientQtThread();
6769
68 bool get_reply(std::string& reply);70 bool get_reply(std::string& reply);
@@ -82,6 +84,7 @@
82private:84private:
83 QUrl url_;85 QUrl url_;
84 const std::function<void(std::string const&)> lineDataCallback_;86 const std::function<void(std::string const&)> lineDataCallback_;
87 HttpHeaders headers_;
85 unsigned int timeout_;88 unsigned int timeout_;
86 std::mutex reply_mutex_;89 std::mutex reply_mutex_;
8790
8891
=== modified file 'include/unity/scopes/internal/smartscopes/SmartScopesClient.h'
--- include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-09-03 14:34:14 +0000
+++ include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-09-25 08:50:05 +0000
@@ -174,6 +174,7 @@
174 VariantMap const& filter_state = VariantMap(),174 VariantMap const& filter_state = VariantMap(),
175 std::string const& locale = "",175 std::string const& locale = "",
176 std::string const& country = "",176 std::string const& country = "",
177 std::string const& user_agent_hdr = "",
177 const unsigned int limit = 0);178 const unsigned int limit = 0);
178179
179 PreviewHandle::UPtr preview(PreviewReplyHandler const& handler,180 PreviewHandle::UPtr preview(PreviewReplyHandler const& handler,
@@ -184,7 +185,8 @@
184 const unsigned int widgets_api_version,185 const unsigned int widgets_api_version,
185 VariantMap const& settings = VariantMap(),186 VariantMap const& settings = VariantMap(),
186 std::string const& locale = "",187 std::string const& locale = "",
187 std::string const& country = "");188 std::string const& country = "",
189 std::string const& user_agent_hdr = "");
188190
189private:191private:
190 friend class SearchHandle;192 friend class SearchHandle;
191193
=== modified file 'src/scopes/internal/smartscopes/HttpClientQt.cpp'
--- src/scopes/internal/smartscopes/HttpClientQt.cpp 2014-09-02 11:58:04 +0000
+++ src/scopes/internal/smartscopes/HttpClientQt.cpp 2014-09-25 08:50:05 +0000
@@ -48,12 +48,13 @@
48{48{
49}49}
5050
51HttpResponseHandle::SPtr HttpClientQt::get(std::string const& request_url, std::function<void(std::string const&)> const& lineData)51HttpResponseHandle::SPtr HttpClientQt::get(std::string const& request_url, std::function<void(std::string const&)> const& lineData,
52 HttpHeaders const& headers)
52{53{
53 std::lock_guard<std::mutex> lock(sessions_mutex_);54 std::lock_guard<std::mutex> lock(sessions_mutex_);
5455
55 // start new session56 // start new session
56 auto session = std::make_shared<HttpSession>(request_url, no_reply_timeout_, lineData);57 auto session = std::make_shared<HttpSession>(request_url, no_reply_timeout_, lineData, headers);
57 sessions_[session_index_] = session;58 sessions_[session_index_] = session;
5859
59 return std::make_shared<HttpResponseHandle>(shared_from_this(), session_index_++, session->get_future());60 return std::make_shared<HttpResponseHandle>(shared_from_this(), session_index_++, session->get_future());
@@ -79,17 +80,18 @@
7980
80//-- HttpClientQt::HttpSession81//-- HttpClientQt::HttpSession
8182
82HttpClientQt::HttpSession::HttpSession(std::string const& request_url, uint timeout, std::function<void(std::string const&)> const& lineData)83HttpClientQt::HttpSession::HttpSession(std::string const& request_url, uint timeout, std::function<void(std::string const&)> const& lineData,
84 HttpHeaders const& headers)
83 : qt_thread_(nullptr)85 : qt_thread_(nullptr)
84{86{
85 get_thread_ =87 get_thread_ =
86 std::thread([this, request_url, timeout, lineData]()88 std::thread([this, request_url, headers, timeout, lineData]()
87 {89 {
88 QUrl url(request_url.c_str());90 QUrl url(request_url.c_str());
8991
90 {92 {
91 std::lock_guard<std::mutex> lock(qt_thread_mutex_);93 std::lock_guard<std::mutex> lock(qt_thread_mutex_);
92 qt_thread_ = std::unique_ptr<HttpClientQtThread>(new HttpClientQtThread(url, timeout, lineData));94 qt_thread_ = std::unique_ptr<HttpClientQtThread>(new HttpClientQtThread(url, timeout, lineData, headers));
93 }95 }
9496
95 QEventLoop loop;97 QEventLoop loop;
9698
=== modified file 'src/scopes/internal/smartscopes/HttpClientQtThread.cpp'
--- src/scopes/internal/smartscopes/HttpClientQtThread.cpp 2014-08-28 15:51:48 +0000
+++ src/scopes/internal/smartscopes/HttpClientQtThread.cpp 2014-09-25 08:50:05 +0000
@@ -38,10 +38,11 @@
38namespace smartscopes38namespace smartscopes
39{39{
4040
41HttpClientQtThread::HttpClientQtThread(const QUrl& url, uint timeout, std::function<void(std::string const&)> const& lineData)41HttpClientQtThread::HttpClientQtThread(const QUrl& url, uint timeout, std::function<void(std::string const&)> const& lineData, HttpHeaders const& headers)
42 : QThread()42 : QThread()
43 , url_(url)43 , url_(url)
44 , lineDataCallback_(lineData)44 , lineDataCallback_(lineData)
45 , headers_(headers)
45 , timeout_(timeout)46 , timeout_(timeout)
46 , success_(false)47 , success_(false)
47{48{
@@ -67,6 +68,10 @@
67 QNetworkAccessManager* manager = new QNetworkAccessManager();68 QNetworkAccessManager* manager = new QNetworkAccessManager();
6869
69 QNetworkRequest request(url_);70 QNetworkRequest request(url_);
71 for (auto const& hdr: headers_)
72 {
73 request.setRawHeader(QString::fromStdString(hdr.first).toUtf8(), QString::fromStdString(hdr.second).toUtf8());
74 }
7075
71 QNetworkReply* reply = manager->get(request);76 QNetworkReply* reply = manager->get(request);
72 reply->setReadBufferSize(0); // unlimited buffer77 reply->setReadBufferSize(0); // unlimited buffer
7378
=== modified file 'src/scopes/internal/smartscopes/SmartScope.cpp'
--- src/scopes/internal/smartscopes/SmartScope.cpp 2014-09-03 14:34:14 +0000
+++ src/scopes/internal/smartscopes/SmartScope.cpp 2014-09-25 08:50:05 +0000
@@ -163,6 +163,7 @@
163 ///! TODO: country (+location data)163 ///! TODO: country (+location data)
164 int query_id = 0;164 int query_id = 0;
165 std::string session_id;165 std::string session_id;
166 std::string agent;
166 auto const metadata = search_metadata();167 auto const metadata = search_metadata();
167 if (metadata.contains_hint("session-id") && metadata["session-id"].which() == Variant::String)168 if (metadata.contains_hint("session-id") && metadata["session-id"].which() == Variant::String)
168 {169 {
@@ -181,8 +182,13 @@
181 {182 {
182 std::cout << "SmartScope: missing or invalid query id for \"" << scope_id_ << "\": \"" << query_.query_string() << "\"" << std::endl;183 std::cout << "SmartScope: missing or invalid query id for \"" << scope_id_ << "\": \"" << query_.query_string() << "\"" << std::endl;
183 }184 }
185 if (metadata.contains_hint("user-agent") && metadata["user-agent"].which() == Variant::String)
186 {
187 agent = metadata["user-agent"].get_string();
188 }
184189
185 search_handle_ = ss_client_->search(handler, base_url_, query_.query_string(), query_.department_id(), session_id, query_id, hints_.form_factor(), settings(), query_.filter_state().serialize(), hints_.locale(), "", hints_.cardinality());190 search_handle_ = ss_client_->search(handler, base_url_, query_.query_string(), query_.department_id(), session_id, query_id, hints_.form_factor(),
191 settings(), query_.filter_state().serialize(), hints_.locale(), "", agent, hints_.cardinality());
186 search_handle_->wait();192 search_handle_->wait();
187193
188 std::cout << "SmartScope: query for \"" << scope_id_ << "\": \"" << query_.query_string() << "\" complete" << std::endl;194 std::cout << "SmartScope: query for \"" << scope_id_ << "\": \"" << query_.query_string() << "\" complete" << std::endl;
@@ -250,8 +256,9 @@
250 }256 }
251 };257 };
252258
253 ///! TODO: widgets_api_version, country (+location data)259 ///! TODO: country (+location data)
254 std::string session_id;260 std::string session_id;
261 std::string agent;
255 auto const metadata = action_metadata();262 auto const metadata = action_metadata();
256 if (metadata.contains_hint("session-id") && metadata["session-id"].which() == Variant::String)263 if (metadata.contains_hint("session-id") && metadata["session-id"].which() == Variant::String)
257 {264 {
@@ -263,7 +270,13 @@
263 std::cout << "SmartScope: missing or invalid session id for \"" << scope_id_ << "\" preview: \"" << result().uri() << "\"" << std::endl;270 std::cout << "SmartScope: missing or invalid session id for \"" << scope_id_ << "\" preview: \"" << result().uri() << "\"" << std::endl;
264 }271 }
265272
266 preview_handle_ = ss_client_->preview(handler, base_url_, result_["result_json"].get_string(), session_id, hints_.form_factor(), 0, settings(), hints_.locale(), "");273 if (metadata.contains_hint("user-agent") && metadata["user-agent"].which() == Variant::String)
274 {
275 agent = metadata["user-agent"].get_string();
276 }
277
278 preview_handle_ = ss_client_->preview(handler, base_url_, result_["result_json"].get_string(), session_id, hints_.form_factor(), 0, settings(),
279 hints_.locale(), "", agent);
267280
268 preview_handle_->wait();281 preview_handle_->wait();
269282
270283
=== modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp'
--- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-09-03 14:34:14 +0000
+++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-09-25 08:50:05 +0000
@@ -335,6 +335,7 @@
335 VariantMap const& filter_state,335 VariantMap const& filter_state,
336 std::string const& locale,336 std::string const& locale,
337 std::string const& country,337 std::string const& country,
338 std::string const& user_agent_hdr,
338 uint limit)339 uint limit)
339{340{
340 std::ostringstream search_uri;341 std::ostringstream search_uri;
@@ -381,6 +382,14 @@
381 uint search_id = ++query_counter_;382 uint search_id = ++query_counter_;
382383
383 std::cout << "SmartScopesClient.search(): GET " << search_uri.str() << std::endl;384 std::cout << "SmartScopesClient.search(): GET " << search_uri.str() << std::endl;
385
386 HttpHeaders headers;
387 if (!user_agent_hdr.empty())
388 {
389 std::cout << "User agent: " << user_agent_hdr;
390 headers.push_back(std::make_pair("User-Agent", user_agent_hdr));
391 }
392
384 query_results_[search_id] = http_client_->get(search_uri.str(), [this, handler](std::string const& lineData) {393 query_results_[search_id] = http_client_->get(search_uri.str(), [this, handler](std::string const& lineData) {
385 try394 try
386 {395 {
@@ -390,7 +399,7 @@
390 {399 {
391 std::cerr << "Failed to parse: " << e.what() << std::endl;400 std::cerr << "Failed to parse: " << e.what() << std::endl;
392 }401 }
393 });402 }, headers);
394403
395 return SearchHandle::UPtr(new SearchHandle(search_id, shared_from_this()));404 return SearchHandle::UPtr(new SearchHandle(search_id, shared_from_this()));
396}405}
@@ -403,6 +412,7 @@
403 const uint widgets_api_version,412 const uint widgets_api_version,
404 VariantMap const& settings,413 VariantMap const& settings,
405 std::string const& locale,414 std::string const& locale,
415 std::string const& user_agent_hdr,
406 std::string const& country)416 std::string const& country)
407{417{
408 std::ostringstream preview_uri;418 std::ostringstream preview_uri;
@@ -415,6 +425,12 @@
415 preview_uri << "&platform=" << platform;425 preview_uri << "&platform=" << platform;
416 preview_uri << "&widgets_api_version=" << std::to_string(widgets_api_version);426 preview_uri << "&widgets_api_version=" << std::to_string(widgets_api_version);
417427
428 HttpHeaders headers;
429 if (!user_agent_hdr.empty())
430 {
431 headers.push_back(std::make_pair("User-Agent", user_agent_hdr));
432 }
433
418 // optional parameters434 // optional parameters
419435
420 if (!settings.empty())436 if (!settings.empty())
@@ -447,7 +463,7 @@
447 {463 {
448 std::cerr << "Failed to parse: " << e.what() << std::endl;464 std::cerr << "Failed to parse: " << e.what() << std::endl;
449 }465 }
450 });466 }, headers);
451467
452 return PreviewHandle::UPtr(new PreviewHandle(preview_id, shared_from_this()));468 return PreviewHandle::UPtr(new PreviewHandle(preview_id, shared_from_this()));
453}469}
454470
=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py'
--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-08-05 15:08:30 +0000
+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-09-25 08:50:05 +0000
@@ -32,6 +32,9 @@
32 if environ['PATH_INFO'] == '/remote-scopes' and (environ['QUERY_STRING'] == '' or environ['QUERY_STRING'] == 'locale=test_TEST'):32 if environ['PATH_INFO'] == '/remote-scopes' and (environ['QUERY_STRING'] == '' or environ['QUERY_STRING'] == 'locale=test_TEST'):
33 return [remote_scopes_response]33 return [remote_scopes_response]
3434
35 if environ['PATH_INFO'] == '/demo/search' and environ['QUERY_STRING'].find('test_user_agent_header') >= 0:
36 return [search_response + '\r\n{"result": {"cat_id": "cat1", "art": "https://dash.ubuntu.com/imgs/cat.png", "uri": "URI", "title": "' + environ['HTTP_USER_AGENT'] + '"}}']
37
35 if environ['PATH_INFO'] == '/demo/search' and environ['QUERY_STRING'] != '':38 if environ['PATH_INFO'] == '/demo/search' and environ['QUERY_STRING'] != '':
36 return [search_response]39 return [search_response]
3740
3841
=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp'
--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-08-28 15:51:48 +0000
+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-09-25 08:50:05 +0000
@@ -140,7 +140,7 @@
140 dept = deptinfo;140 dept = deptinfo;
141 };141 };
142142
143 auto search_handle = ssc_->search(handler, sss_url_ + "/demo", "stuff", "", "session_id", 0, "platform");143 auto search_handle = ssc_->search(handler, sss_url_ + "/demo", "stuff", "", "session_id", 0, "platform", VariantMap(), VariantMap(), "en_US", "", "ThisIsUserAgentHeader");
144 search_handle->wait();144 search_handle->wait();
145145
146 ASSERT_EQ(3u, results.size());146 ASSERT_EQ(3u, results.size());
@@ -221,6 +221,32 @@
221 EXPECT_EQ(active_option->id(), "salesrank");221 EXPECT_EQ(active_option->id(), "salesrank");
222}222}
223223
224TEST_F(SmartScopesClientTest, userAgentHeader)
225{
226 std::vector<SearchResult> results;
227
228 SearchReplyHandler handler;
229 handler.filters_handler = [](Filters const &) {
230 };
231 handler.filter_state_handler = [](FilterState const&) {
232 };
233 handler.category_handler = [](std::shared_ptr<SearchCategory> const&) {
234 };
235 handler.result_handler = [&results](SearchResult const& result) {
236 results.push_back(result);
237 };
238 handler.departments_handler = [](std::shared_ptr<DepartmentInfo> const&) {
239 };
240
241 auto search_handle = ssc_->search(handler, sss_url_ + "/demo", "test_user_agent_header", "", "session_id", 0, "platform", VariantMap(), VariantMap(), "en_US", "", "ThisIsUserAgentHeader");
242 search_handle->wait();
243
244 ASSERT_EQ(4u, results.size());
245
246 // user agent string is expected in the result title
247 EXPECT_EQ("ThisIsUserAgentHeader", results[3].other_params["title"]->as_string());
248}
249
224TEST_F(SmartScopesClientTest, preview)250TEST_F(SmartScopesClientTest, preview)
225{251{
226 PreviewReplyHandler handler;252 PreviewReplyHandler handler;

Subscribers

People subscribed via source and target branches

to all changes: