Skip to content
Snippets Groups Projects
Commit eb3731a3 authored by Don Kjer's avatar Don Kjer
Browse files

svn merge -r 61099:61168 svn+ssh://svn/svn/linden/branches/release-candidate into release

parent 4ecb9cb6
No related branches found
No related tags found
No related merge requests found
...@@ -218,24 +218,11 @@ LLURI LLURI::buildHTTP(const std::string& prefix, ...@@ -218,24 +218,11 @@ LLURI LLURI::buildHTTP(const std::string& prefix,
const LLSD& path, const LLSD& path,
const LLSD& query) const LLSD& query)
{ {
LLURI result = buildHTTP(prefix, path); LLURI uri = buildHTTP(prefix, path);
uri.mEscapedQuery = mapToQueryString(query);
// break out and escape each query component // break out and escape each query component
if (query.isMap()) uri.mEscapedOpaque += "?" + uri.mEscapedQuery ;
{ return uri;
for (LLSD::map_const_iterator it = query.beginMap();
it != query.endMap();
it++)
{
result.mEscapedQuery += escapeQueryVariable(it->first) +
(it->second.isUndefined() ? "" : "=" + escapeQueryValue(it->second.asString())) +
"&";
}
if (query.size() > 0)
{
result.mEscapedOpaque += "?" + result.mEscapedQuery;
}
}
return result;
} }
// static // static
...@@ -255,7 +242,6 @@ LLURI LLURI::buildHTTP(const std::string& host, ...@@ -255,7 +242,6 @@ LLURI LLURI::buildHTTP(const std::string& host,
return LLURI::buildHTTP(llformat("%s:%u", host.c_str(), port), path, query); return LLURI::buildHTTP(llformat("%s:%u", host.c_str(), port), path, query);
} }
namespace { namespace {
LLURI buildBackboneURL(LLApp* app, LLURI buildBackboneURL(LLApp* app,
const std::string& p1 = "", const std::string& p1 = "",
...@@ -507,3 +493,23 @@ LLSD LLURI::queryMap(std::string escaped_query_string) ...@@ -507,3 +493,23 @@ LLSD LLURI::queryMap(std::string escaped_query_string)
return result; return result;
} }
std::string LLURI::mapToQueryString(const LLSD& queryMap)
{
std::string query_string;
if (queryMap.isMap())
{
for (LLSD::map_const_iterator iter = queryMap.beginMap();
iter != queryMap.endMap();
iter++)
{
query_string += escapeQueryVariable(iter->first) +
(iter->second.isUndefined() ? "" : "=" + escapeQueryValue(iter->second.asString())) + "&" ;
}
//if (queryMap.size() > 0)
//{
// query_string += "?" + query_string ;
//}
}
return query_string;
}
...@@ -70,6 +70,7 @@ class LLURI ...@@ -70,6 +70,7 @@ class LLURI
std::string query() const; // ex.: "x=34", section after "?" std::string query() const; // ex.: "x=34", section after "?"
LLSD queryMap() const; // above decoded into a map LLSD queryMap() const; // above decoded into a map
static LLSD queryMap(std::string escaped_query_string); static LLSD queryMap(std::string escaped_query_string);
static std::string mapToQueryString(const LLSD& queryMap);
// Escaping Utilities // Escaping Utilities
// Escape a string by urlencoding all the characters that aren't in the allowed string. // Escape a string by urlencoding all the characters that aren't in the allowed string.
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "llsdserialize.h" #include "llsdserialize.h"
#include "llvfile.h" #include "llvfile.h"
#include "llvfs.h" #include "llvfs.h"
#include "lluri.h"
#include "message.h" #include "message.h"
#include <curl/curl.h> #include <curl/curl.h>
...@@ -263,6 +264,14 @@ void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const F32 ...@@ -263,6 +264,14 @@ void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const F32
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout); request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout);
} }
void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const F32 timeout)
{
LLURI uri;
uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query);
get(uri.asString(), responder, timeout);
}
// A simple class for managing data returned from a curl http request. // A simple class for managing data returned from a curl http request.
class LLHTTPBuffer class LLHTTPBuffer
{ {
......
...@@ -53,6 +53,7 @@ class LLHTTPClient ...@@ -53,6 +53,7 @@ class LLHTTPClient
typedef boost::intrusive_ptr<Responder> ResponderPtr; typedef boost::intrusive_ptr<Responder> ResponderPtr;
static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
static void get(const std::string& url, const LLSD& query, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
///< non-blocking ///< non-blocking
static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment