summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-10-30 14:54:59 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-11-01 23:09:24 +0100
commit9bc2582c31d10b49f9070a99848e96951f6b66c5 (patch)
treeea3f48c25c7cc6389329778297bb7ad15d4afcf5
parentf0b4bc12f82869f1e95a480e52ea0adb6eb58971 (diff)
downloadcurl-9bc2582c31d10b49f9070a99848e96951f6b66c5.tar.gz
resume: consider a resume from [content-length] to be OK
Basically since servers often then don't respond well to this and instead send the full contents and then libcurl would instead error out with the assumption that the server doesn't support resume. As the data is then already transfered, this is now considered fine. Test case 1434 added to verify this. Test case 1042 slightly modified. Reported-by: hugo Bug: http://curl.haxx.se/bug/view.cgi?id=1443
-rw-r--r--lib/transfer.c12
-rw-r--r--tests/data/Makefile.inc2
-rw-r--r--tests/data/test10426
-rw-r--r--tests/data/test143490
4 files changed, 106 insertions, 4 deletions
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
</server>
<name>
-HTTP GET from end of entirely-downloaded file, no server resume
+HTTP GET beyond end of entirely-downloaded file, no server resume
</name>
<command>
-http://%HOSTIP:%HTTPPORT/1042 -C -
+http://%HOSTIP:%HTTPPORT/1042 -C 200
</command>
<file name="log/curl1042.out">
012345678
@@ -85,7 +85,7 @@ http://%HOSTIP:%HTTPPORT/1042 -C -
</strip>
<protocol>
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 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+Resume
+</keywords>
+</info>
+
+# Server-side
+<reply>
+# Some servers (e.g. Apache 1.2) respond this way to an invalid byte range
+<data>
+HTTP/1.1 200 OK
+Connection: close
+Content-Length: 100
+Content-Type: text/plain
+
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+</data>
+
+# The file data that exists at the start of the test must be included in
+# the verification.
+<datacheck>
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+HTTP/1.1 200 OK
+Connection: close
+Content-Length: 100
+Content-Type: text/plain
+
+</datacheck>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP GET resume at exactly the existing file size is fine
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/1434 -C 100
+</command>
+<file name="log/curl1434.out">
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+012345678
+</file>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /1434 HTTP/1.1
+Range: bytes=100-
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+
+</protocol>
+</verify>
+</testcase>