add set_web_seeds to torrent_info
This commit is contained in:
parent
550b0bb047
commit
121b686a39
|
@ -285,6 +285,9 @@ namespace libtorrent
|
||||||
// url/http seeds. Currently, the only transport protocol supported for
|
// url/http seeds. Currently, the only transport protocol supported for
|
||||||
// the url is http.
|
// the url is http.
|
||||||
//
|
//
|
||||||
|
// ``set_web_seeds()`` replaces all web seeds with the ones specified in
|
||||||
|
// the ``seeds`` vector.
|
||||||
|
//
|
||||||
// The ``extern_auth`` argument can be used for other athorization
|
// The ``extern_auth`` argument can be used for other athorization
|
||||||
// schemese than basic HTTP authorization. If set, it will override any
|
// schemese than basic HTTP authorization. If set, it will override any
|
||||||
// username and password found in the URL itself. The string will be sent
|
// username and password found in the URL itself. The string will be sent
|
||||||
|
@ -301,8 +304,8 @@ namespace libtorrent
|
||||||
void add_http_seed(std::string const& url
|
void add_http_seed(std::string const& url
|
||||||
, std::string const& extern_auth = std::string()
|
, std::string const& extern_auth = std::string()
|
||||||
, web_seed_entry::headers_t const& extra_headers = web_seed_entry::headers_t());
|
, web_seed_entry::headers_t const& extra_headers = web_seed_entry::headers_t());
|
||||||
std::vector<web_seed_entry> const& web_seeds() const
|
std::vector<web_seed_entry> const& web_seeds() const { return m_web_seeds; }
|
||||||
{ return m_web_seeds; }
|
void set_web_seeds(std::vector<web_seed_entry> seeds);
|
||||||
|
|
||||||
// ``total_size()``, ``piece_length()`` and ``num_pieces()`` returns the
|
// ``total_size()``, ``piece_length()`` and ``num_pieces()`` returns the
|
||||||
// total number of bytes the torrent-file represents (all the files in
|
// total number of bytes the torrent-file represents (all the files in
|
||||||
|
|
|
@ -1688,6 +1688,11 @@ namespace libtorrent
|
||||||
, auth, extra_headers));
|
, auth, extra_headers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void torrent_info::set_web_seeds(std::vector<web_seed_entry> seeds)
|
||||||
|
{
|
||||||
|
m_web_seeds = seeds;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<sha1_hash> torrent_info::similar_torrents() const
|
std::vector<sha1_hash> torrent_info::similar_torrents() const
|
||||||
{
|
{
|
||||||
std::vector<sha1_hash> ret;
|
std::vector<sha1_hash> ret;
|
||||||
|
|
|
@ -173,12 +173,53 @@ test_failing_torrent_t test_error_torrents[] =
|
||||||
// TODO: torrent with an SSL cert
|
// TODO: torrent with an SSL cert
|
||||||
// TODO: torrent with attributes (executable and hidden)
|
// TODO: torrent with attributes (executable and hidden)
|
||||||
// TODO: torrent_info::add_tracker
|
// TODO: torrent_info::add_tracker
|
||||||
// TODO: torrent_info::add_url_seed
|
|
||||||
// TODO: torrent_info::add_http_seed
|
|
||||||
// TODO: torrent_info::unload
|
// TODO: torrent_info::unload
|
||||||
// TODO: torrent_info constructor that takes an invalid bencoded buffer
|
// TODO: torrent_info constructor that takes an invalid bencoded buffer
|
||||||
// TODO: verify_encoding with a string that triggers character replacement
|
// TODO: verify_encoding with a string that triggers character replacement
|
||||||
|
|
||||||
|
TORRENT_TEST(add_url_seed)
|
||||||
|
{
|
||||||
|
torrent_info ti(sha1_hash(" "));
|
||||||
|
TEST_EQUAL(ti.web_seeds().size(), 0);
|
||||||
|
|
||||||
|
ti.add_url_seed("http://test.com");
|
||||||
|
|
||||||
|
TEST_EQUAL(ti.web_seeds().size(), 1);
|
||||||
|
web_seed_entry we = ti.web_seeds()[0];
|
||||||
|
TEST_EQUAL(we.type, web_seed_entry::url_seed);
|
||||||
|
TEST_EQUAL(we.url, "http://test.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
TORRENT_TEST(add_http_seed)
|
||||||
|
{
|
||||||
|
torrent_info ti(sha1_hash(" "));
|
||||||
|
TEST_EQUAL(ti.web_seeds().size(), 0);
|
||||||
|
|
||||||
|
ti.add_http_seed("http://test.com");
|
||||||
|
|
||||||
|
TEST_EQUAL(ti.web_seeds().size(), 1);
|
||||||
|
web_seed_entry we = ti.web_seeds()[0];
|
||||||
|
TEST_EQUAL(we.type, web_seed_entry::http_seed);
|
||||||
|
TEST_EQUAL(we.url, "http://test.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
TORRENT_TEST(set_web_seeds)
|
||||||
|
{
|
||||||
|
torrent_info ti(sha1_hash(" "));
|
||||||
|
TEST_EQUAL(ti.web_seeds().size(), 0);
|
||||||
|
|
||||||
|
std::vector<web_seed_entry> seeds;
|
||||||
|
web_seed_entry e1("http://test1.com", web_seed_entry::url_seed);
|
||||||
|
seeds.push_back(e1);
|
||||||
|
web_seed_entry e2("http://test2com", web_seed_entry::http_seed);
|
||||||
|
seeds.push_back(e2);
|
||||||
|
|
||||||
|
ti.set_web_seeds(seeds);
|
||||||
|
|
||||||
|
TEST_EQUAL(ti.web_seeds().size(), 2);
|
||||||
|
TEST_CHECK(ti.web_seeds() == seeds);
|
||||||
|
}
|
||||||
|
|
||||||
TORRENT_TEST(sanitize_path)
|
TORRENT_TEST(sanitize_path)
|
||||||
{
|
{
|
||||||
// test sanitize_append_path_element
|
// test sanitize_append_path_element
|
||||||
|
|
Loading…
Reference in New Issue