mirror of https://github.com/aria2/aria2
BitTorrent: Allow 32KiB request
It looks like the 32KiB is the default request size of python bittorrent client. Previously, aria2 only allowed maximum 16KiB request.pull/675/head
parent
c7d242e27d
commit
e220c53849
|
@ -46,7 +46,7 @@ constexpr size_t PIECE_HASH_LENGTH = 20;
|
|||
|
||||
constexpr size_t PEER_ID_LENGTH = 20;
|
||||
|
||||
constexpr size_t MAX_BLOCK_LENGTH = 16_k;
|
||||
constexpr size_t MAX_BLOCK_LENGTH = 32_k;
|
||||
|
||||
constexpr size_t DEFAULT_MAX_OUTSTANDING_REQUEST = 6;
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ void BtPieceMessage::send()
|
|||
|
||||
void BtPieceMessage::pushPieceData(int64_t offset, int32_t length) const
|
||||
{
|
||||
assert(length <= static_cast<int32_t>(16_k));
|
||||
assert(length <= static_cast<int32_t>(MAX_BLOCK_LENGTH));
|
||||
auto buf = std::vector<unsigned char>(length + MESSAGE_HEADER_LENGTH);
|
||||
createMessageHeader(buf.data());
|
||||
ssize_t r;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "SocketBuffer.h"
|
||||
#include "Command.h"
|
||||
#include "a2functional.h"
|
||||
#include "BtConstants.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -53,7 +54,7 @@ class ARC4Encryptor;
|
|||
// The maximum length of buffer. If the message length (including 4
|
||||
// bytes length and payload length) is larger than this value, it is
|
||||
// dropped.
|
||||
constexpr size_t MAX_BUFFER_CAPACITY = 16_k + 128;
|
||||
constexpr size_t MAX_BUFFER_CAPACITY = MAX_BLOCK_LENGTH + 128;
|
||||
|
||||
class PeerConnection {
|
||||
private:
|
||||
|
|
|
@ -266,7 +266,7 @@ void BtRequestMessageTest::testValidate()
|
|||
|
||||
void BtRequestMessageTest::testValidate_lengthTooLong()
|
||||
{
|
||||
BtRequestMessage msg(0, 0, 16_k + 1);
|
||||
BtRequestMessage msg(0, 0, 32_k + 1);
|
||||
msg.setBtMessageValidator(
|
||||
make_unique<RangeBtMessageValidator>(&msg, 1_k, 256_k));
|
||||
try {
|
||||
|
@ -274,7 +274,7 @@ void BtRequestMessageTest::testValidate_lengthTooLong()
|
|||
CPPUNIT_FAIL("exception must be thrown.");
|
||||
}
|
||||
catch (DlAbortEx& e) {
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Length too long: 16385 > 16KB"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Length too long: 32769 > 32KB"),
|
||||
std::string(e.what()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ void PeerConnectionTest::testReserveBuffer()
|
|||
CPPUNIT_ASSERT_EQUAL((size_t)MAX_BUFFER_CAPACITY, con.getBufferCapacity());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, con.getBufferLength());
|
||||
|
||||
constexpr size_t newLength = 32_k;
|
||||
constexpr size_t newLength = 64_k;
|
||||
con.reserveBuffer(newLength);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(newLength, con.getBufferCapacity());
|
||||
|
|
Loading…
Reference in New Issue