mirror of https://github.com/aria2/aria2
always use range requests
Send "Range: bytes=0-" with the first http request to inform the server of range support by the client. As per RFC 7233, server MUST ignore the header (not request!) if it doesn't support range requests or the specified unit. So, this should have no side effects. Fixes GH-1576.pull/1587/head
parent
2924a029ab
commit
83cb6c15d3
|
@ -213,6 +213,9 @@ std::string HttpRequest::createRequest()
|
|||
}
|
||||
builtinHds.emplace_back("Range:", rangeHeader);
|
||||
}
|
||||
else if (!segment_ && getMethod() == "GET") {
|
||||
builtinHds.emplace_back("Range:", "bytes=0-");
|
||||
}
|
||||
if (proxyRequest_) {
|
||||
if (request_->isKeepAliveEnabled() || request_->isPipeliningEnabled()) {
|
||||
builtinHds.emplace_back("Connection:", "Keep-Alive");
|
||||
|
|
|
@ -527,6 +527,7 @@ void HttpRequestTest::testCreateRequest_query()
|
|||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Range: bytes=0-\r\n"
|
||||
"\r\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
@ -624,6 +625,7 @@ void HttpRequestTest::testCreateRequest_wantDigest()
|
|||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Range: bytes=0-\r\n"
|
||||
"Want-Digest: " +
|
||||
wantDigest +
|
||||
"\r\n"
|
||||
|
@ -781,6 +783,7 @@ void HttpRequestTest::testUserAgent()
|
|||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Range: bytes=0-\r\n"
|
||||
"\r\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
@ -818,6 +821,7 @@ void HttpRequestTest::testAddHeader()
|
|||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Range: bytes=0-\r\n"
|
||||
"X-ARIA2: v0.13\r\n"
|
||||
"X-ARIA2-DISTRIBUTE: enabled\r\n"
|
||||
"Accept: text/html\r\n"
|
||||
|
@ -847,6 +851,7 @@ void HttpRequestTest::testAcceptMetalink()
|
|||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Range: bytes=0-\r\n"
|
||||
"\r\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
|
@ -876,6 +881,7 @@ void HttpRequestTest::testEnableAcceptEncoding()
|
|||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Range: bytes=0-\r\n"
|
||||
"\r\n";
|
||||
|
||||
std::string expectedText = expectedTextHead;
|
||||
|
|
Loading…
Reference in New Issue