diff --git a/lib/transfer.c b/lib/transfer.c index b5ba86eb4..6d4ad43fa 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -547,6 +547,18 @@ static CURLcode readwrite_data(struct SessionHandle *data, if(data->state.resume_from && !k->content_range && (data->set.httpreq==HTTPREQ_GET) && !k->ignorebody) { + + if(k->size == data->state.resume_from) { + /* The resume point is at the end of file, consider this fine + even if it doesn't allow resume from here. */ + infof(data, "The entire document is already downloaded"); + connclose(conn, "already downloaded"); + /* Abort download */ + k->keepon &= ~KEEP_RECV; + *done = TRUE; + return CURLE_OK; + } + /* we wanted to resume a download, although the server doesn't * seem to support this and we did this with a GET (if it * wasn't a GET we did a POST or PUT resume) */ diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index 6d21d670b..ee9585742 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -142,7 +142,7 @@ test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \ test1408 test1409 test1410 test1411 test1412 test1413 test1414 test1415 \ test1416 test1417 test1418 test1419 test1420 \ \ -test1428 test1429 test1430 test1431 test1432 test1433 \ +test1428 test1429 test1430 test1431 test1432 test1433 test1434 \ \ test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \ test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \ diff --git a/tests/data/test1042 b/tests/data/test1042 index d532120d9..f9a2255e1 100644 --- a/tests/data/test1042 +++ b/tests/data/test1042 @@ -56,10 +56,10 @@ Content-Type: text/plain http -HTTP GET from end of entirely-downloaded file, no server resume +HTTP GET beyond end of entirely-downloaded file, no server resume -http://%HOSTIP:%HTTPPORT/1042 -C - +http://%HOSTIP:%HTTPPORT/1042 -C 200 012345678 @@ -85,7 +85,7 @@ http://%HOSTIP:%HTTPPORT/1042 -C - GET /1042 HTTP/1.1 -Range: bytes=100- +Range: bytes=200- Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test1434 b/tests/data/test1434 new file mode 100644 index 000000000..fba104b83 --- /dev/null +++ b/tests/data/test1434 @@ -0,0 +1,90 @@ + + + +HTTP +HTTP GET +Resume + + + +# Server-side + +# Some servers (e.g. Apache 1.2) respond this way to an invalid byte range + +HTTP/1.1 200 OK +Connection: close +Content-Length: 100 +Content-Type: text/plain + +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 + + +# The file data that exists at the start of the test must be included in +# the verification. + +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +HTTP/1.1 200 OK +Connection: close +Content-Length: 100 +Content-Type: text/plain + + + + +# Client-side + + +http + + +HTTP GET resume at exactly the existing file size is fine + + +http://%HOSTIP:%HTTPPORT/1434 -C 100 + + +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 +012345678 + + + +# Verify data after the test has been "shot" + + +^User-Agent:.* + + +GET /1434 HTTP/1.1 +Range: bytes=100- +Host: %HOSTIP:%HTTPPORT +Accept: */* + + + +