work on test_web_seed
This commit is contained in:
parent
5ff529d4b1
commit
bc851d317f
|
@ -2821,7 +2821,9 @@ ret:
|
|||
|
||||
if (m_storage_mode != internal_storage_mode_compact_deprecated) return piece_index;
|
||||
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
INVARIANT_CHECK;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(piece_index >= 0);
|
||||
TORRENT_ASSERT(piece_index < (int)m_piece_to_slot.size());
|
||||
|
|
|
@ -956,6 +956,7 @@ void web_server_thread(int* port, bool ssl, bool chunked)
|
|||
}
|
||||
|
||||
std::string path = p.path();
|
||||
fprintf(stderr, "%s\n", path.c_str());
|
||||
|
||||
if (path == "/redirect")
|
||||
{
|
||||
|
@ -1098,6 +1099,14 @@ void web_server_thread(int* port, bool ssl, bool chunked)
|
|||
char eh[400];
|
||||
snprintf(eh, sizeof(eh), "Content-Range: bytes %d-%d\r\n", start, end);
|
||||
extra_header[1] = eh;
|
||||
if (end - start + 1 >= 1000)
|
||||
{
|
||||
fprintf(stderr, "request size: %.2f kB\n", int(end - start + 1)/1000.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "request size: %d Bytes\n", int(end - start + 1));
|
||||
}
|
||||
send_response(s, ec, 206, "Partial", extra_header, end - start + 1);
|
||||
if (!file_buf.empty())
|
||||
{
|
||||
|
|
|
@ -220,7 +220,17 @@ int run_suite(char const* protocol, bool test_url_seed, bool chunked_encoding)
|
|||
std::generate(random_data, random_data + 300000, &std::rand);
|
||||
char filename[200];
|
||||
snprintf(filename, sizeof(filename), "tmp1_web_seed/test_torrent_dir/test%d", i);
|
||||
save_file(filename, random_data, file_sizes[i]);
|
||||
int to_write = file_sizes[i];
|
||||
file f(filename, file::write_only, ec);
|
||||
size_type offset = 0;
|
||||
while (to_write > 0)
|
||||
{
|
||||
int s = (std::min)(to_write, 300000);
|
||||
file::iovec_t b = { random_data, s};
|
||||
f.writev(offset, &b, 1, ec);
|
||||
offset += s;
|
||||
to_write -= s;
|
||||
}
|
||||
}
|
||||
|
||||
add_files(fs, "tmp1_web_seed/test_torrent_dir");
|
||||
|
|
Loading…
Reference in New Issue