Esempio n. 1
0
void URI::SetPath(const Aws::String& value, bool shouldEncode)
{
    //we need to url encode the path parts (mainly to take care of spaces that a user might put here)
    if (shouldEncode)
    {
        Aws::Vector<Aws::String> pathParts = StringUtils::Split(value, '/');
        Aws::StringStream ss;

        for (Aws::Vector<Aws::String>::iterator iter = pathParts.begin(); iter != pathParts.end(); ++iter)
        {
            ss << '/' << StringUtils::URLEncode(iter->c_str());
        }

        //if the last character was also a slash, then add that back here.
        if (value[value.length() - 1] == '/')
        {
            ss << '/';
        }

        path = ss.str();
    }
    else
    {
        path = value;
    }
}
Esempio n. 2
0
Aws::String URI::URLEncodePath(const Aws::String& path)
{
    Aws::Vector<Aws::String> pathParts = StringUtils::Split(path, '/');
    Aws::StringStream ss;

    for (Aws::Vector<Aws::String>::iterator iter = pathParts.begin(); iter != pathParts.end(); ++iter)
    {
        ss << '/' << StringUtils::URLEncode(iter->c_str());
    }

    //if the last character was also a slash, then add that back here.
    if (path[path.length() - 1] == '/')
    {
        ss << '/';
    }

    return ss.str();
}