aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/lluri.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:56 -0500
committerJacek Antonelli2008-08-15 23:44:56 -0500
commitc07901e29ed545bbb02e3bddf148fe1104b94e9f (patch)
treef1ada64ce834acd7d92a425efb96c4b86bcf16b1 /linden/indra/llcommon/lluri.cpp
parentSecond Life viewer sources 1.15.0.2 (diff)
downloadmeta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.zip
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.gz
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.bz2
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.xz
Second Life viewer sources 1.15.1.3
Diffstat (limited to 'linden/indra/llcommon/lluri.cpp')
-rw-r--r--linden/indra/llcommon/lluri.cpp84
1 files changed, 66 insertions, 18 deletions
diff --git a/linden/indra/llcommon/lluri.cpp b/linden/indra/llcommon/lluri.cpp
index f85f294..c838b25 100644
--- a/linden/indra/llcommon/lluri.cpp
+++ b/linden/indra/llcommon/lluri.cpp
@@ -114,6 +114,13 @@ namespace
114 { return LLURI::escape(s, unreserved() + ":@!$'()*+,="); } // sub_delims - "&;" + ":@" 114 { return LLURI::escape(s, unreserved() + ":@!$'()*+,="); } // sub_delims - "&;" + ":@"
115} 115}
116 116
117// TODO: USE CURL!! After http textures gets merged everywhere.
118// static
119std::string LLURI::escape(const std::string& str)
120{
121 return escape(str,unreserved() + ":@!$'()*+,=");
122}
123
117LLURI::LLURI() 124LLURI::LLURI()
118{ 125{
119} 126}
@@ -238,24 +245,11 @@ LLURI LLURI::buildHTTP(const std::string& prefix,
238 const LLSD& path, 245 const LLSD& path,
239 const LLSD& query) 246 const LLSD& query)
240{ 247{
241 LLURI result = buildHTTP(prefix, path); 248 LLURI uri = buildHTTP(prefix, path);
249 uri.mEscapedQuery = mapToQueryString(query);
242 // break out and escape each query component 250 // break out and escape each query component
243 if (query.isMap()) 251 uri.mEscapedOpaque += "?" + uri.mEscapedQuery ;
244 { 252 return uri;
245 for (LLSD::map_const_iterator it = query.beginMap();
246 it != query.endMap();
247 it++)
248 {
249 result.mEscapedQuery += escapeQueryVariable(it->first) +
250 (it->second.isUndefined() ? "" : "=" + escapeQueryValue(it->second.asString())) +
251 "&";
252 }
253 if (query.size() > 0)
254 {
255 result.mEscapedOpaque += "?" + result.mEscapedQuery;
256 }
257 }
258 return result;
259} 253}
260 254
261// static 255// static
@@ -275,7 +269,6 @@ LLURI LLURI::buildHTTP(const std::string& host,
275 return LLURI::buildHTTP(llformat("%s:%u", host.c_str(), port), path, query); 269 return LLURI::buildHTTP(llformat("%s:%u", host.c_str(), port), path, query);
276} 270}
277 271
278
279namespace { 272namespace {
280 LLURI buildBackboneURL(LLApp* app, 273 LLURI buildBackboneURL(LLApp* app,
281 const std::string& p1 = "", 274 const std::string& p1 = "",
@@ -317,6 +310,23 @@ LLURI LLURI::buildBulkAgentNamesURI(LLApp* app)
317} 310}
318 311
319// static 312// static
313LLURI LLURI::buildBulkAgentNamesURI(LLApp* app)
314{
315 std::string host = "localhost:12040";
316
317 if (app)
318 {
319 host = app->getOption("backbone-host-port").asString();
320 }
321
322 LLSD path = LLSD::emptyArray();
323 path.append("agent");
324 path.append("names");
325
326 return buildHTTP(host, path);
327}
328
329// static
320LLURI LLURI::buildAgentSessionURI(const LLUUID& agent_id, LLApp* app) 330LLURI LLURI::buildAgentSessionURI(const LLUUID& agent_id, LLApp* app)
321{ 331{
322 return buildBackboneURL(app, "agent", agent_id.asString(), "session"); 332 return buildBackboneURL(app, "agent", agent_id.asString(), "session");
@@ -341,6 +351,24 @@ LLURI LLURI::buildAgentNameURI(const LLUUID& agent_id, LLApp* app)
341} 351}
342 352
343// static 353// static
354LLURI LLURI::buildAgentNameURI(const LLUUID& agent_id, LLApp* app)
355{
356 std::string host = "localhost:12040";
357
358 if (app)
359 {
360 host = app->getOption("backbone-host-port").asString();
361 }
362
363 LLSD path = LLSD::emptyArray();
364 path.append("agent");
365 path.append(agent_id);
366 path.append("name");
367
368 return buildHTTP(host, path);
369}
370
371// static
344LLURI LLURI::buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& dataserver) 372LLURI LLURI::buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& dataserver)
345{ 373{
346 LLSD path = LLSD::emptyArray(); 374 LLSD path = LLSD::emptyArray();
@@ -492,3 +520,23 @@ LLSD LLURI::queryMap(std::string escaped_query_string)
492 return result; 520 return result;
493} 521}
494 522
523std::string LLURI::mapToQueryString(const LLSD& queryMap)
524{
525 std::string query_string;
526
527 if (queryMap.isMap())
528 {
529 for (LLSD::map_const_iterator iter = queryMap.beginMap();
530 iter != queryMap.endMap();
531 iter++)
532 {
533 query_string += escapeQueryVariable(iter->first) +
534 (iter->second.isUndefined() ? "" : "=" + escapeQueryValue(iter->second.asString())) + "&" ;
535 }
536 //if (queryMap.size() > 0)
537 //{
538 // query_string += "?" + query_string ;
539 //}
540 }
541 return query_string;
542}