#include <lluri.h>
Parts of a URI | |
std::string | scheme () const |
ex.: "http", note lack of colon | |
std::string | opaque () const |
everything after the colon | |
std::string | authority () const |
std::string | hostName () const |
std::string | userName () const |
std::string | password () const |
U16 | hostPort () const |
BOOL | defaultPort () const |
const std::string & | escapedPath () const |
std::string | path () const |
LLSD | pathArray () const |
std::string | query () const |
const std::string & | escapedQuery () const |
LLSD | queryMap () const |
static LLSD | queryMap (std::string escaped_query_string) |
static std::string | mapToQueryString (const LLSD &query_map) |
given a name value map, return a serialized query string. | |
Public Member Functions | |
LLURI () | |
LLURI (const std::string &escaped_str) | |
LLURI (const std::string &scheme, const std::string &userName, const std::string &password, const std::string &hostName, U16 hostPort, const std::string &escapedPath, const std::string &escapedQuery) | |
~LLURI () | |
std::string | asString () const |
the whole URI, escaped as needed | |
Static Public Member Functions | |
static LLURI | buildHTTP (const std::string &prefix, const LLSD &path) |
static LLURI | buildHTTP (const std::string &prefix, const LLSD &path, const LLSD &query) |
static LLURI | buildHTTP (const std::string &host, const U32 &port, const LLSD &path) |
static LLURI | buildHTTP (const std::string &host, const U32 &port, const LLSD &path, const LLSD &query) |
Escaping Utilities | |
static std::string | escape (const std::string &str) |
Escape a raw url with a reasonable set of allowed characters. | |
static std::string | escape (const std::string &str, const std::string &allowed, bool is_allowed_sorted=false) |
Escape a string with a specified set of allowed characters. | |
static std::string | unescape (const std::string &str) |
unescape an escaped URI string. | |
Private Member Functions | |
void | parseAuthorityAndPathUsingOpaque () |
Private Attributes | |
std::string | mScheme |
std::string | mEscapedOpaque |
std::string | mEscapedAuthority |
std::string | mEscapedPath |
std::string | mEscapedQuery |
Definition at line 49 of file lluri.h.
LLURI::LLURI | ( | ) |
Definition at line 178 of file lluri.cpp.
Referenced by buildHTTP().
LLURI::LLURI | ( | const std::string & | escaped_str | ) |
Definition at line 182 of file lluri.cpp.
References mEscapedOpaque, mEscapedPath, mEscapedQuery, mScheme, and parseAuthorityAndPathUsingOpaque().
LLURI::LLURI | ( | const std::string & | scheme, | |
const std::string & | userName, | |||
const std::string & | password, | |||
const std::string & | hostName, | |||
U16 | hostPort, | |||
const std::string & | escapedPath, | |||
const std::string & | escapedQuery | |||
) |
Definition at line 268 of file lluri.cpp.
References escape(), isDefault(), mEscapedAuthority, mEscapedOpaque, and opaque().
Definition at line 310 of file lluri.cpp.
References LLSD::asString(), LLSD::beginArray(), LLSD::endArray(), escapeHostAndPort(), escapePathComponent(), LLSD::isArray(), LLSD::isString(), LLSD::isUndefined(), lldebugs, llendl, LLURI(), llwarns, mEscapedAuthority, mEscapedOpaque, mEscapedPath, mScheme, and LLSD::type().
Referenced by buildHTTP(), LLHTTPClient::get(), and update_dialog_callback().
LLURI LLURI::buildHTTP | ( | const std::string & | prefix, | |
const LLSD & | path, | |||
const LLSD & | query | |||
) | [static] |
prefix is either a full URL prefix of the form "http://example.com:8080", or it can be simply a host and optional port like "example.com" or "example.com:8080", in these cases, the "http://" will be added
Definition at line 358 of file lluri.cpp.
References buildHTTP(), mapToQueryString(), mEscapedOpaque, and mEscapedQuery.
Definition at line 371 of file lluri.cpp.
References buildHTTP(), and llformat().
LLURI LLURI::buildHTTP | ( | const std::string & | host, | |
const U32 & | port, | |||
const LLSD & | path, | |||
const LLSD & | query | |||
) | [static] |
Definition at line 379 of file lluri.cpp.
References buildHTTP(), and llformat().
std::string LLURI::asString | ( | ) | const |
the whole URI, escaped as needed
Definition at line 387 of file lluri.cpp.
References mEscapedOpaque, and mScheme.
Referenced by tut::ensure_equals(), LLHTTPClient::get(), LLAres::UriRewriteResponder::queryError(), LLAres::UriRewriteResponder::queryResult(), and update_dialog_callback().
std::string LLURI::scheme | ( | ) | const |
ex.: "http", note lack of colon
Definition at line 399 of file lluri.cpp.
References mScheme.
Referenced by tut::URITestData::checkParts(), cursor_from_parcel_media(), handle_click_action_open_media(), LLFloaterURLEntry::onBtnOK(), LLViewerMediaImpl::play(), LLAres::UriRewriteResponder::queryResult(), and LLAres::rewriteURI().
std::string LLURI::opaque | ( | ) | const |
everything after the colon
Definition at line 404 of file lluri.cpp.
References mEscapedOpaque, and unescape().
Referenced by tut::URITestData::checkParts(), and LLURI().
std::string LLURI::authority | ( | ) | const |
Definition at line 409 of file lluri.cpp.
References mEscapedAuthority, and unescape().
Referenced by tut::URITestData::checkParts().
std::string LLURI::hostName | ( | ) | const |
Definition at line 447 of file lluri.cpp.
References findAuthorityParts(), mEscapedAuthority, and unescape().
Referenced by LLAres::rewriteURI().
std::string LLURI::userName | ( | ) | const |
Definition at line 454 of file lluri.cpp.
References findAuthorityParts(), mEscapedAuthority, and unescape().
Referenced by LLAres::UriRewriteResponder::queryResult().
std::string LLURI::password | ( | ) | const |
Definition at line 466 of file lluri.cpp.
References findAuthorityParts(), mEscapedAuthority, and unescape().
Referenced by LLAres::UriRewriteResponder::queryResult().
U16 LLURI::hostPort | ( | ) | const |
Definition at line 483 of file lluri.cpp.
References findAuthorityParts(), mEscapedAuthority, and mScheme.
Referenced by defaultPort(), and LLAres::UriRewriteResponder::queryResult().
BOOL LLURI::defaultPort | ( | ) | const |
Definition at line 478 of file lluri.cpp.
References hostPort(), isDefault(), and mScheme.
Referenced by LLAres::UriRewriteResponder::queryResult().
const std::string& LLURI::escapedPath | ( | ) | const [inline] |
Definition at line 108 of file lluri.h.
References mEscapedPath.
Referenced by LLAres::UriRewriteResponder::queryResult().
std::string LLURI::path | ( | ) | const |
Definition at line 500 of file lluri.cpp.
References mEscapedPath, and unescape().
Referenced by tut::URITestData::checkParts().
LLSD LLURI::pathArray | ( | ) | const |
Definition at line 505 of file lluri.cpp.
References LLSD::append(), and mEscapedPath.
Referenced by LLURLDispatcherImpl::dispatchApp().
std::string LLURI::query | ( | ) | const |
Definition at line 521 of file lluri.cpp.
References mEscapedQuery, and unescape().
Referenced by tut::URITestData::checkParts().
const std::string& LLURI::escapedQuery | ( | ) | const [inline] |
Definition at line 112 of file lluri.h.
References mEscapedQuery.
Referenced by LLAres::UriRewriteResponder::queryResult().
LLSD LLURI::queryMap | ( | ) | const |
Definition at line 526 of file lluri.cpp.
References mEscapedQuery.
Referenced by LLURLDispatcherImpl::dispatchApp(), LLPanelLogin::loadLoginPage(), and LLLoginHandler::parseDirectLogin().
LLSD LLURI::queryMap | ( | std::string | escaped_query_string | ) | [static] |
Definition at line 532 of file lluri.cpp.
References LLSD::emptyArray(), lldebugs, llendl, and unescape().
std::string LLURI::mapToQueryString | ( | const LLSD & | query_map | ) | [static] |
given a name value map, return a serialized query string.
query_map | a map of name value. every value must be representable as a string. |
Definition at line 572 of file lluri.cpp.
References LLSD::beginMap(), LLSD::endMap(), escapeQueryValue(), escapeQueryVariable(), and LLSD::isMap().
Referenced by buildHTTP(), and LLServiceBuilder::buildServiceURI().
std::string LLURI::escape | ( | const std::string & | str | ) | [static] |
Escape a raw url with a reasonable set of allowed characters.
The default set was chosen to match HTTP urls and general guidelines for naming resources. Passing in a raw url does not produce well defined results because you really need to know which segments are path parts because path parts are supposed to be escaped individually. The default set chosen is:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 0123456789 -._~ :@!$'()*+,=/?&#;
*NOTE: This API is basically broken because it does not allow you to specify significant path characters. For example, if the filename actually contained a /, then you cannot use this function to generate the serialized url for that resource.
str | The raw URI to escape. |
Definition at line 166 of file lluri.cpp.
References unreserved().
Referenced by LLPanelDirFind::buildSearchURL(), escape(), escapeHostAndPort(), escapePathComponent(), escapeQueryValue(), escapeQueryVariable(), tut::URITestData::escapeRoundTrip(), LLPanelDirFind::getSearchURLSuffix(), LLURI(), and LLVoiceClient::sessionCreateSendMessage().
std::string LLURI::escape | ( | const std::string & | str, | |
const std::string & | allowed, | |||
bool | is_allowed_sorted = false | |||
) | [static] |
Escape a string with a specified set of allowed characters.
Escape a string by urlencoding all the characters that aren't in the allowed string.
str | The raw URI to escape. | |
allowed | Character array of allowed characters | |
is_allowed_sorted | Optimization hint if allowed array is sorted. |
Definition at line 55 of file lluri.cpp.
References encode_character(), and escape().
std::string LLURI::unescape | ( | const std::string & | str | ) | [static] |
unescape an escaped URI string.
str | The escped URI to unescape. |
Definition at line 113 of file lluri.cpp.
References hex_as_nybble().
Referenced by authority(), tut::URITestData::escapeRoundTrip(), hostName(), opaque(), password(), path(), query(), queryMap(), and userName().
void LLURI::parseAuthorityAndPathUsingOpaque | ( | ) | [private] |
Definition at line 220 of file lluri.cpp.
References mEscapedAuthority, mEscapedOpaque, mEscapedPath, and mScheme.
Referenced by LLURI().
std::string LLURI::mScheme [private] |
Definition at line 183 of file lluri.h.
Referenced by asString(), buildHTTP(), defaultPort(), hostPort(), LLURI(), parseAuthorityAndPathUsingOpaque(), and scheme().
std::string LLURI::mEscapedOpaque [private] |
Definition at line 184 of file lluri.h.
Referenced by asString(), buildHTTP(), LLURI(), opaque(), and parseAuthorityAndPathUsingOpaque().
std::string LLURI::mEscapedAuthority [private] |
Definition at line 185 of file lluri.h.
Referenced by authority(), buildHTTP(), hostName(), hostPort(), LLURI(), parseAuthorityAndPathUsingOpaque(), password(), and userName().
std::string LLURI::mEscapedPath [private] |
Definition at line 186 of file lluri.h.
Referenced by buildHTTP(), escapedPath(), LLURI(), parseAuthorityAndPathUsingOpaque(), path(), and pathArray().
std::string LLURI::mEscapedQuery [private] |
Definition at line 187 of file lluri.h.
Referenced by buildHTTP(), escapedQuery(), LLURI(), query(), and queryMap().