mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
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
This commit is contained in:
parent
f0b4bc12f8
commit
9bc2582c31
@ -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) */
|
||||
|
@ -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 \
|
||||
|
@ -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: */*
|
||||
|
||||
|
90
tests/data/test1434
Normal file
90
tests/data/test1434
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user