コード例 #1
0
storage_uri::storage_uri(const web::http::uri& primary_uri, const web::http::uri& secondary_uri)
    : m_primary_uri(primary_uri), m_secondary_uri(secondary_uri)
{
    if (primary_uri.is_empty())
    {
        throw std::invalid_argument("primary_uri");
    }

    if (!secondary_uri.is_empty() &&
            (primary_uri.resource() != secondary_uri.resource()))
    {
        throw std::invalid_argument(utility::conversions::to_utf8string(protocol::error_storage_uri_mismatch));
    }
}
コード例 #2
0
    web::http::uri generate_queue_uri(const web::http::uri& base_uri, const utility::string_t& prefix, bool get_metadata, int max_results, const continuation_token& continuation_token)
    {
        if (base_uri.is_empty())
        {
            return web::http::uri();
        }

        web::http::uri_builder builder(base_uri);

        if (!prefix.empty())
        {
            builder.append_query(U("prefix"), prefix);
        }

        if (get_metadata)
        {
            builder.append_query(U("include"), U("metadata"));
        }

        if (max_results >= 0)
        {
            builder.append_query(U("maxresults"), max_results);
        }

        if (!continuation_token.empty())
        {
            builder.append_query(continuation_token.next_marker());
        }

        return builder.to_uri();
    }
コード例 #3
0
    web::http::uri generate_queue_uri(const web::http::uri& base_uri, const utility::string_t& prefix, bool get_metadata, int max_results, const continuation_token& token)
    {
        if (base_uri.is_empty())
        {
            return web::http::uri();
        }

        web::http::uri_builder builder(base_uri);

        if (!prefix.empty())
        {
            builder.append_query(core::make_query_parameter(uri_query_prefix, prefix));
        }

        if (get_metadata)
        {
            builder.append_query(core::make_query_parameter(uri_query_include, component_metadata, /* do_encoding */ false));
        }

        if (max_results > 0)
        {
            builder.append_query(core::make_query_parameter(uri_query_max_results, max_results, /* do_encoding */ false));
        }

        if (!token.empty())
        {
            builder.append_query(token.next_marker());
        }

        return builder.to_uri();
    }
コード例 #4
0
web::http::uri blob_service_test_base::defiddler(const web::http::uri& uri)
{
    if (uri.host() == U("ipv4.fiddler"))
    {
        web::http::uri_builder builder(uri);
        builder.set_host(U("127.0.0.1"));
        return builder.to_uri();
    }

    return uri;
}
コード例 #5
0
    web::http::uri generate_queue_uri(const web::http::uri& base_uri, const cloud_queue& queue)
    {
        if (base_uri.is_empty())
        {
            return web::http::uri();
        }

        web::http::uri_builder builder(base_uri);
        builder.append_path(queue.name(), /* do_encoding */ true);
        return builder.to_uri();
    }
コード例 #6
0
    storage_credentials parse_query(const web::http::uri& uri, bool require_signed_resource)
    {
        // Order of the strings in the sas_parameters vector is per MSDN's
        // definition of Shared Access Signatures.
        const utility::string_t sas_parameters[] = {
            protocol::uri_query_sas_version,
            protocol::uri_query_sas_resource,
            protocol::uri_query_sas_table_name,
            protocol::uri_query_sas_start,
            protocol::uri_query_sas_expiry,
            protocol::uri_query_sas_permissions,
            protocol::uri_query_sas_start_partition_key,
            protocol::uri_query_sas_start_row_key,
            protocol::uri_query_sas_end_partition_key,
            protocol::uri_query_sas_end_row_key,
            protocol::uri_query_sas_identifier,
            protocol::uri_query_sas_cache_control,
            protocol::uri_query_sas_content_disposition,
            protocol::uri_query_sas_content_encoding,
            protocol::uri_query_sas_content_language,
            protocol::uri_query_sas_content_type,
            protocol::uri_query_sas_signature,
        };

        const int sas_parameters_size = (int) (sizeof(sas_parameters) / sizeof(sas_parameters[0]));

        auto splitted_query = web::http::uri::split_query(uri.query());

        bool params_found = false;
        web::http::uri_builder builder;
        for (int i = 0; i < sas_parameters_size; ++i)
        {
            auto param = splitted_query.find(sas_parameters[i]);
            if (param != splitted_query.end())
            {
                params_found = true;
                add_query_if_not_empty(builder, param->first, param->second, /* do_encoding */ false);
            }
        }

        if (!params_found)
        {
            return storage_credentials();
        }

        auto signature = splitted_query.find(protocol::uri_query_sas_signature);
        auto signed_resource = splitted_query.find(protocol::uri_query_sas_resource);
        if ((signature == splitted_query.end()) || (require_signed_resource && (signed_resource == splitted_query.end())))
        {
            throw std::invalid_argument(protocol::error_missing_params_for_sas);
        }

        return storage_credentials(builder.query());
    }
コード例 #7
0
    web::http::uri generate_queue_message_uri(const web::http::uri& base_uri, const cloud_queue& queue, const utility::string_t& message_id)
    {
        if (base_uri.is_empty())
        {
            return web::http::uri();
        }

        web::http::uri_builder builder(base_uri);
        builder.append_path(queue.name(), /* do_encoding */ true);
        builder.append_path(_XPLATSTR("messages"));
        builder.append_path(message_id, /* do_encoding */ true);

        return builder.to_uri();
    }
コード例 #8
0
    cloud_storage_account cloud_storage_account::get_development_storage_account(const web::http::uri& proxy_uri)
    {
        web::http::uri_builder builder;
        if (!proxy_uri.is_empty())
        {
            builder.set_scheme(proxy_uri.scheme());
            builder.set_host(proxy_uri.host());
        }
        else
        {
            builder.set_scheme(U("http"));
            builder.set_host(U("127.0.0.1"));
        }

        builder.set_path(devstore_account_name);

        builder.set_port(10000);
        auto blob_endpoint = storage_uri(builder.to_uri());

        builder.set_port(10001);
        auto queue_endpoint = storage_uri(builder.to_uri());

        builder.set_port(10002);
        auto table_endpoint = storage_uri(builder.to_uri());

        auto credentials = storage_credentials(devstore_account_name, devstore_account_key);
        auto account = cloud_storage_account(credentials, blob_endpoint, queue_endpoint, table_endpoint);
        
        account.m_is_development_storage_account = true;
        account.m_settings.insert(std::make_pair(use_development_storage_setting_string, use_development_storage_setting_value));
        if (!proxy_uri.is_empty())
        {
            account.m_settings.insert(std::make_pair(development_storage_proxy_uri_setting_string, proxy_uri.to_string()));
        }
        
        return account;
    }