Loading lib/file.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -183,11 +183,11 @@ CURLcode Curl_file(struct connectdata *conn) return res; return res; now = Curl_tvnow(); now = Curl_tvnow(); if(Curl_pgrsUpdate(data)) if(Curl_pgrsUpdate(conn)) res = CURLE_ABORTED_BY_CALLBACK; res = CURLE_ABORTED_BY_CALLBACK; } } now = Curl_tvnow(); now = Curl_tvnow(); if(Curl_pgrsUpdate(data)) if(Curl_pgrsUpdate(conn)) res = CURLE_ABORTED_BY_CALLBACK; res = CURLE_ABORTED_BY_CALLBACK; close(fd); close(fd); Loading lib/ftp.c +25 −24 Original line number Original line Diff line number Diff line Loading @@ -1272,7 +1272,7 @@ again:; CURLE_FTP_COULDNT_SET_BINARY; CURLE_FTP_COULDNT_SET_BINARY; } } if(data->resume_from) { if(conn->resume_from) { /* we're about to continue the uploading of a file */ /* we're about to continue the uploading of a file */ /* 1. get already existing file's size. We use the SIZE /* 1. get already existing file's size. We use the SIZE command for this which may not exist in the server! command for this which may not exist in the server! Loading @@ -1286,7 +1286,7 @@ again:; /* 4. lower the infilesize counter */ /* 4. lower the infilesize counter */ /* => transfer as usual */ /* => transfer as usual */ if(data->resume_from < 0 ) { if(conn->resume_from < 0 ) { /* we could've got a specified offset from the command line, /* we could've got a specified offset from the command line, but now we know we didn't */ but now we know we didn't */ Loading @@ -1302,10 +1302,10 @@ again:; } } /* get the size from the ascii string: */ /* get the size from the ascii string: */ data->resume_from = atoi(buf+4); conn->resume_from = atoi(buf+4); } } if(data->resume_from) { if(conn->resume_from) { /* do we still game? */ /* do we still game? */ int passed=0; int passed=0; /* enable append instead */ /* enable append instead */ Loading @@ -1315,7 +1315,7 @@ again:; input. If we knew it was a proper file we could've just input. If we knew it was a proper file we could've just fseek()ed but we only have a stream here */ fseek()ed but we only have a stream here */ do { do { int readthisamountnow = (data->resume_from - passed); int readthisamountnow = (conn->resume_from - passed); int actuallyread; int actuallyread; if(readthisamountnow > BUFSIZE) if(readthisamountnow > BUFSIZE) Loading @@ -1331,11 +1331,11 @@ again:; return CURLE_FTP_COULDNT_USE_REST; return CURLE_FTP_COULDNT_USE_REST; } } } } while(passed != data->resume_from); while(passed != conn->resume_from); /* now, decrease the size of the read */ /* now, decrease the size of the read */ if(data->infilesize>0) { if(data->infilesize>0) { data->infilesize -= data->resume_from; data->infilesize -= conn->resume_from; if(data->infilesize <= 0) { if(data->infilesize <= 0) { failf(data, "File already completely uploaded\n"); failf(data, "File already completely uploaded\n"); Loading Loading @@ -1387,13 +1387,13 @@ again:; bool dirlist=FALSE; bool dirlist=FALSE; long downloadsize=-1; long downloadsize=-1; if(data->bits.set_range && data->range) { if(conn->bits.use_range && conn->range) { long from, to; long from, to; int totalsize=-1; int totalsize=-1; char *ptr; char *ptr; char *ptr2; char *ptr2; from=strtol(data->range, &ptr, 0); from=strtol(conn->range, &ptr, 0); while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) ptr++; ptr++; to=strtol(ptr, &ptr2, 0); to=strtol(ptr, &ptr2, 0); Loading @@ -1403,22 +1403,23 @@ again:; } } if((-1 == to) && (from>=0)) { if((-1 == to) && (from>=0)) { /* X - */ /* X - */ data->resume_from = from; conn->resume_from = from; infof(data, "FTP RANGE %d to end of file\n", from); infof(data, "FTP RANGE %d to end of file\n", from); } } else if(from < 0) { else if(from < 0) { /* -Y */ /* -Y */ totalsize = -from; totalsize = -from; conn->maxdownload = -from; conn->maxdownload = -from; data->resume_from = from; conn->resume_from = from; infof(data, "FTP RANGE the last %d bytes\n", totalsize); infof(data, "FTP RANGE the last %d bytes\n", totalsize); } } else { else { /* X-Y */ /* X-Y */ totalsize = to-from; totalsize = to-from; conn->maxdownload = totalsize+1; /* include the last mentioned byte */ conn->maxdownload = totalsize+1; /* include the last mentioned byte */ data->resume_from = from; conn->resume_from = from; infof(data, "FTP RANGE from %d getting %d bytes\n", from, conn->maxdownload); infof(data, "FTP RANGE from %d getting %d bytes\n", from, conn->maxdownload); } } infof(data, "range-download from %d to %d, totally %d bytes\n", infof(data, "range-download from %d to %d, totally %d bytes\n", from, to, totalsize); from, to, totalsize); Loading Loading @@ -1466,7 +1467,7 @@ again:; CURLE_FTP_COULDNT_SET_BINARY; CURLE_FTP_COULDNT_SET_BINARY; } } if(data->resume_from) { if(conn->resume_from) { /* Daniel: (August 4, 1999) /* Daniel: (August 4, 1999) * * Loading @@ -1491,26 +1492,26 @@ again:; int foundsize=atoi(buf+4); int foundsize=atoi(buf+4); /* We got a file size report, so we check that there actually is a /* We got a file size report, so we check that there actually is a part of the file left to get, or else we go home. */ part of the file left to get, or else we go home. */ if(data->resume_from< 0) { if(conn->resume_from< 0) { /* We're supposed to download the last abs(from) bytes */ /* We're supposed to download the last abs(from) bytes */ if(foundsize < -data->resume_from) { if(foundsize < -conn->resume_from) { failf(data, "Offset (%d) was beyond file size (%d)", failf(data, "Offset (%d) was beyond file size (%d)", data->resume_from, foundsize); conn->resume_from, foundsize); return CURLE_FTP_BAD_DOWNLOAD_RESUME; return CURLE_FTP_BAD_DOWNLOAD_RESUME; } } /* convert to size to download */ /* convert to size to download */ downloadsize = -data->resume_from; downloadsize = -conn->resume_from; /* download from where? */ /* download from where? */ data->resume_from = foundsize - downloadsize; conn->resume_from = foundsize - downloadsize; } } else { else { if(foundsize < data->resume_from) { if(foundsize < conn->resume_from) { failf(data, "Offset (%d) was beyond file size (%d)", failf(data, "Offset (%d) was beyond file size (%d)", data->resume_from, foundsize); conn->resume_from, foundsize); return CURLE_FTP_BAD_DOWNLOAD_RESUME; return CURLE_FTP_BAD_DOWNLOAD_RESUME; } } /* Now store the number of bytes we are expected to download */ /* Now store the number of bytes we are expected to download */ downloadsize = foundsize-data->resume_from; downloadsize = foundsize-conn->resume_from; } } } } Loading @@ -1521,9 +1522,9 @@ again:; /* Set resume file transfer offset */ /* Set resume file transfer offset */ infof(data, "Instructs server to resume from offset %d\n", infof(data, "Instructs server to resume from offset %d\n", data->resume_from); conn->resume_from); ftpsendf(conn->firstsocket, conn, "REST %d", data->resume_from); ftpsendf(conn->firstsocket, conn, "REST %d", conn->resume_from); nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode); nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode); if(nread < 0) if(nread < 0) Loading lib/http.c +14 −14 Original line number Original line Diff line number Diff line Loading @@ -497,7 +497,7 @@ CURLcode Curl_http(struct connectdata *conn) if((data->bits.http_post || if((data->bits.http_post || data->bits.http_formpost || data->bits.http_formpost || data->bits.http_put) && data->bits.http_put) && data->resume_from) { conn->resume_from) { /********************************************************************** /********************************************************************** * Resuming upload in HTTP means that we PUT or POST and that we have * Resuming upload in HTTP means that we PUT or POST and that we have * got a resume_from value set. The resume value has already created * got a resume_from value set. The resume value has already created Loading @@ -506,15 +506,15 @@ CURLcode Curl_http(struct connectdata *conn) * file size before we continue this venture in the dark lands of HTTP. * file size before we continue this venture in the dark lands of HTTP. *********************************************************************/ *********************************************************************/ if(data->resume_from < 0 ) { if(conn->resume_from < 0 ) { /* /* * This is meant to get the size of the present remote-file by itself. * This is meant to get the size of the present remote-file by itself. * We don't support this now. Bail out! * We don't support this now. Bail out! */ */ data->resume_from = 0; conn->resume_from = 0; } } if(data->resume_from) { if(conn->resume_from) { /* do we still game? */ /* do we still game? */ int passed=0; int passed=0; Loading @@ -522,7 +522,7 @@ CURLcode Curl_http(struct connectdata *conn) input. If we knew it was a proper file we could've just input. If we knew it was a proper file we could've just fseek()ed but we only have a stream here */ fseek()ed but we only have a stream here */ do { do { int readthisamountnow = (data->resume_from - passed); int readthisamountnow = (conn->resume_from - passed); int actuallyread; int actuallyread; if(readthisamountnow > BUFSIZE) if(readthisamountnow > BUFSIZE) Loading @@ -537,11 +537,11 @@ CURLcode Curl_http(struct connectdata *conn) passed); passed); return CURLE_READ_ERROR; return CURLE_READ_ERROR; } } } while(passed != data->resume_from); /* loop until done */ } while(passed != conn->resume_from); /* loop until done */ /* now, decrease the size of the read */ /* now, decrease the size of the read */ if(data->infilesize>0) { if(data->infilesize>0) { data->infilesize -= data->resume_from; data->infilesize -= conn->resume_from; if(data->infilesize <= 0) { if(data->infilesize <= 0) { failf(data, "File already completely uploaded\n"); failf(data, "File already completely uploaded\n"); Loading @@ -551,7 +551,7 @@ CURLcode Curl_http(struct connectdata *conn) /* we've passed, proceed as normal */ /* we've passed, proceed as normal */ } } } } if(data->bits.set_range) { if(conn->bits.use_range) { /* /* * A range is selected. We use different headers whether we're downloading * A range is selected. We use different headers whether we're downloading * or uploading and we always let customized headers override our internal * or uploading and we always let customized headers override our internal Loading @@ -559,23 +559,23 @@ CURLcode Curl_http(struct connectdata *conn) */ */ if((data->httpreq == HTTPREQ_GET) && if((data->httpreq == HTTPREQ_GET) && !checkheaders(data, "Range:")) { !checkheaders(data, "Range:")) { conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", data->range); conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", conn->range); } } else if((data->httpreq != HTTPREQ_GET) && else if((data->httpreq != HTTPREQ_GET) && !checkheaders(data, "Content-Range:")) { !checkheaders(data, "Content-Range:")) { if(data->resume_from) { if(conn->resume_from) { /* This is because "resume" was selected */ /* This is because "resume" was selected */ long total_expected_size= data->resume_from + data->infilesize; long total_expected_size= conn->resume_from + data->infilesize; conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n", conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n", data->range, total_expected_size-1, conn->range, total_expected_size-1, total_expected_size); total_expected_size); } } else { else { /* Range was selected and then we just pass the incoming range and /* Range was selected and then we just pass the incoming range and append total size */ append total size */ conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%d\r\n", conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%d\r\n", data->range, data->infilesize); conn->range, data->infilesize); } } } } } } Loading Loading @@ -610,7 +610,7 @@ CURLcode Curl_http(struct connectdata *conn) conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"", conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"", (conn->bits.user_passwd && conn->allocptr.userpwd)? (conn->bits.user_passwd && conn->allocptr.userpwd)? conn->allocptr.userpwd:"", conn->allocptr.userpwd:"", (data->bits.set_range && conn->allocptr.rangeline)? (conn->bits.use_range && conn->allocptr.rangeline)? conn->allocptr.rangeline:"", conn->allocptr.rangeline:"", (data->useragent && *data->useragent && conn->allocptr.uagent)? (data->useragent && *data->useragent && conn->allocptr.uagent)? conn->allocptr.uagent:"", conn->allocptr.uagent:"", Loading lib/progress.c +9 −5 Original line number Original line Diff line number Diff line Loading @@ -91,11 +91,12 @@ static char *max5data(double bytes, char *max5) */ */ void Curl_pgrsDone(struct UrlData *data) void Curl_pgrsDone(struct connectdata *conn) { { struct UrlData *data = conn->data; if(!(data->progress.flags & PGRS_HIDE)) { if(!(data->progress.flags & PGRS_HIDE)) { data->progress.lastshow=0; data->progress.lastshow=0; Curl_pgrsUpdate(data); /* the final (forced) update */ Curl_pgrsUpdate(conn); /* the final (forced) update */ fprintf(data->err, "\n"); fprintf(data->err, "\n"); } } } } Loading Loading @@ -172,7 +173,7 @@ void Curl_pgrsSetUploadSize(struct UrlData *data, double size) */ */ int Curl_pgrsUpdate(struct UrlData *data) int Curl_pgrsUpdate(struct connectdata *conn) { { struct timeval now; struct timeval now; int result; int result; Loading @@ -185,6 +186,8 @@ int Curl_pgrsUpdate(struct UrlData *data) double total_transfer; double total_transfer; double total_expected_transfer; double total_expected_transfer; struct UrlData *data = conn->data; int nowindex = data->progress.speeder_c% CURR_TIME; int nowindex = data->progress.speeder_c% CURR_TIME; int checkindex; int checkindex; int count; int count; Loading @@ -198,15 +201,16 @@ int Curl_pgrsUpdate(struct UrlData *data) double total_estimate; double total_estimate; if(data->progress.flags & PGRS_HIDE) if(data->progress.flags & PGRS_HIDE) ; /* We do enter this function even if we don't wanna see anything, since ; /* We do enter this function even if we don't wanna see anything, since this is were lots of the calculations are being made that will be used this is were lots of the calculations are being made that will be used even when not displayed! */ even when not displayed! */ else if(!(data->progress.flags & PGRS_HEADERS_OUT)) { else if(!(data->progress.flags & PGRS_HEADERS_OUT)) { if (!data->progress.callback) { if (!data->progress.callback) { if(data->resume_from) if(conn->resume_from) fprintf(data->err, "** Resuming transfer from byte position %d\n", fprintf(data->err, "** Resuming transfer from byte position %d\n", data->resume_from); conn->resume_from); fprintf(data->err, fprintf(data->err, " %% Total %% Received %% Xferd Average Speed Time Curr.\n" " %% Total %% Received %% Xferd Average Speed Time Curr.\n" " Dload Upload Total Current Left Speed\n"); " Dload Upload Total Current Left Speed\n"); Loading lib/progress.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -36,13 +36,13 @@ typedef enum { TIMER_LAST /* must be last */ TIMER_LAST /* must be last */ } timerid; } timerid; void Curl_pgrsDone(struct UrlData *data); void Curl_pgrsDone(struct connectdata *); void Curl_pgrsStartNow(struct UrlData *data); void Curl_pgrsStartNow(struct UrlData *data); void Curl_pgrsSetDownloadSize(struct UrlData *data, double size); void Curl_pgrsSetDownloadSize(struct UrlData *data, double size); void Curl_pgrsSetUploadSize(struct UrlData *data, double size); void Curl_pgrsSetUploadSize(struct UrlData *data, double size); void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size); void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size); void Curl_pgrsSetUploadCounter(struct UrlData *data, double size); void Curl_pgrsSetUploadCounter(struct UrlData *data, double size); int Curl_pgrsUpdate(struct UrlData *data); int Curl_pgrsUpdate(struct connectdata *); void Curl_pgrsTime(struct UrlData *data, timerid timer); void Curl_pgrsTime(struct UrlData *data, timerid timer); Loading Loading
lib/file.c +2 −2 Original line number Original line Diff line number Diff line Loading @@ -183,11 +183,11 @@ CURLcode Curl_file(struct connectdata *conn) return res; return res; now = Curl_tvnow(); now = Curl_tvnow(); if(Curl_pgrsUpdate(data)) if(Curl_pgrsUpdate(conn)) res = CURLE_ABORTED_BY_CALLBACK; res = CURLE_ABORTED_BY_CALLBACK; } } now = Curl_tvnow(); now = Curl_tvnow(); if(Curl_pgrsUpdate(data)) if(Curl_pgrsUpdate(conn)) res = CURLE_ABORTED_BY_CALLBACK; res = CURLE_ABORTED_BY_CALLBACK; close(fd); close(fd); Loading
lib/ftp.c +25 −24 Original line number Original line Diff line number Diff line Loading @@ -1272,7 +1272,7 @@ again:; CURLE_FTP_COULDNT_SET_BINARY; CURLE_FTP_COULDNT_SET_BINARY; } } if(data->resume_from) { if(conn->resume_from) { /* we're about to continue the uploading of a file */ /* we're about to continue the uploading of a file */ /* 1. get already existing file's size. We use the SIZE /* 1. get already existing file's size. We use the SIZE command for this which may not exist in the server! command for this which may not exist in the server! Loading @@ -1286,7 +1286,7 @@ again:; /* 4. lower the infilesize counter */ /* 4. lower the infilesize counter */ /* => transfer as usual */ /* => transfer as usual */ if(data->resume_from < 0 ) { if(conn->resume_from < 0 ) { /* we could've got a specified offset from the command line, /* we could've got a specified offset from the command line, but now we know we didn't */ but now we know we didn't */ Loading @@ -1302,10 +1302,10 @@ again:; } } /* get the size from the ascii string: */ /* get the size from the ascii string: */ data->resume_from = atoi(buf+4); conn->resume_from = atoi(buf+4); } } if(data->resume_from) { if(conn->resume_from) { /* do we still game? */ /* do we still game? */ int passed=0; int passed=0; /* enable append instead */ /* enable append instead */ Loading @@ -1315,7 +1315,7 @@ again:; input. If we knew it was a proper file we could've just input. If we knew it was a proper file we could've just fseek()ed but we only have a stream here */ fseek()ed but we only have a stream here */ do { do { int readthisamountnow = (data->resume_from - passed); int readthisamountnow = (conn->resume_from - passed); int actuallyread; int actuallyread; if(readthisamountnow > BUFSIZE) if(readthisamountnow > BUFSIZE) Loading @@ -1331,11 +1331,11 @@ again:; return CURLE_FTP_COULDNT_USE_REST; return CURLE_FTP_COULDNT_USE_REST; } } } } while(passed != data->resume_from); while(passed != conn->resume_from); /* now, decrease the size of the read */ /* now, decrease the size of the read */ if(data->infilesize>0) { if(data->infilesize>0) { data->infilesize -= data->resume_from; data->infilesize -= conn->resume_from; if(data->infilesize <= 0) { if(data->infilesize <= 0) { failf(data, "File already completely uploaded\n"); failf(data, "File already completely uploaded\n"); Loading Loading @@ -1387,13 +1387,13 @@ again:; bool dirlist=FALSE; bool dirlist=FALSE; long downloadsize=-1; long downloadsize=-1; if(data->bits.set_range && data->range) { if(conn->bits.use_range && conn->range) { long from, to; long from, to; int totalsize=-1; int totalsize=-1; char *ptr; char *ptr; char *ptr2; char *ptr2; from=strtol(data->range, &ptr, 0); from=strtol(conn->range, &ptr, 0); while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-'))) ptr++; ptr++; to=strtol(ptr, &ptr2, 0); to=strtol(ptr, &ptr2, 0); Loading @@ -1403,22 +1403,23 @@ again:; } } if((-1 == to) && (from>=0)) { if((-1 == to) && (from>=0)) { /* X - */ /* X - */ data->resume_from = from; conn->resume_from = from; infof(data, "FTP RANGE %d to end of file\n", from); infof(data, "FTP RANGE %d to end of file\n", from); } } else if(from < 0) { else if(from < 0) { /* -Y */ /* -Y */ totalsize = -from; totalsize = -from; conn->maxdownload = -from; conn->maxdownload = -from; data->resume_from = from; conn->resume_from = from; infof(data, "FTP RANGE the last %d bytes\n", totalsize); infof(data, "FTP RANGE the last %d bytes\n", totalsize); } } else { else { /* X-Y */ /* X-Y */ totalsize = to-from; totalsize = to-from; conn->maxdownload = totalsize+1; /* include the last mentioned byte */ conn->maxdownload = totalsize+1; /* include the last mentioned byte */ data->resume_from = from; conn->resume_from = from; infof(data, "FTP RANGE from %d getting %d bytes\n", from, conn->maxdownload); infof(data, "FTP RANGE from %d getting %d bytes\n", from, conn->maxdownload); } } infof(data, "range-download from %d to %d, totally %d bytes\n", infof(data, "range-download from %d to %d, totally %d bytes\n", from, to, totalsize); from, to, totalsize); Loading Loading @@ -1466,7 +1467,7 @@ again:; CURLE_FTP_COULDNT_SET_BINARY; CURLE_FTP_COULDNT_SET_BINARY; } } if(data->resume_from) { if(conn->resume_from) { /* Daniel: (August 4, 1999) /* Daniel: (August 4, 1999) * * Loading @@ -1491,26 +1492,26 @@ again:; int foundsize=atoi(buf+4); int foundsize=atoi(buf+4); /* We got a file size report, so we check that there actually is a /* We got a file size report, so we check that there actually is a part of the file left to get, or else we go home. */ part of the file left to get, or else we go home. */ if(data->resume_from< 0) { if(conn->resume_from< 0) { /* We're supposed to download the last abs(from) bytes */ /* We're supposed to download the last abs(from) bytes */ if(foundsize < -data->resume_from) { if(foundsize < -conn->resume_from) { failf(data, "Offset (%d) was beyond file size (%d)", failf(data, "Offset (%d) was beyond file size (%d)", data->resume_from, foundsize); conn->resume_from, foundsize); return CURLE_FTP_BAD_DOWNLOAD_RESUME; return CURLE_FTP_BAD_DOWNLOAD_RESUME; } } /* convert to size to download */ /* convert to size to download */ downloadsize = -data->resume_from; downloadsize = -conn->resume_from; /* download from where? */ /* download from where? */ data->resume_from = foundsize - downloadsize; conn->resume_from = foundsize - downloadsize; } } else { else { if(foundsize < data->resume_from) { if(foundsize < conn->resume_from) { failf(data, "Offset (%d) was beyond file size (%d)", failf(data, "Offset (%d) was beyond file size (%d)", data->resume_from, foundsize); conn->resume_from, foundsize); return CURLE_FTP_BAD_DOWNLOAD_RESUME; return CURLE_FTP_BAD_DOWNLOAD_RESUME; } } /* Now store the number of bytes we are expected to download */ /* Now store the number of bytes we are expected to download */ downloadsize = foundsize-data->resume_from; downloadsize = foundsize-conn->resume_from; } } } } Loading @@ -1521,9 +1522,9 @@ again:; /* Set resume file transfer offset */ /* Set resume file transfer offset */ infof(data, "Instructs server to resume from offset %d\n", infof(data, "Instructs server to resume from offset %d\n", data->resume_from); conn->resume_from); ftpsendf(conn->firstsocket, conn, "REST %d", data->resume_from); ftpsendf(conn->firstsocket, conn, "REST %d", conn->resume_from); nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode); nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode); if(nread < 0) if(nread < 0) Loading
lib/http.c +14 −14 Original line number Original line Diff line number Diff line Loading @@ -497,7 +497,7 @@ CURLcode Curl_http(struct connectdata *conn) if((data->bits.http_post || if((data->bits.http_post || data->bits.http_formpost || data->bits.http_formpost || data->bits.http_put) && data->bits.http_put) && data->resume_from) { conn->resume_from) { /********************************************************************** /********************************************************************** * Resuming upload in HTTP means that we PUT or POST and that we have * Resuming upload in HTTP means that we PUT or POST and that we have * got a resume_from value set. The resume value has already created * got a resume_from value set. The resume value has already created Loading @@ -506,15 +506,15 @@ CURLcode Curl_http(struct connectdata *conn) * file size before we continue this venture in the dark lands of HTTP. * file size before we continue this venture in the dark lands of HTTP. *********************************************************************/ *********************************************************************/ if(data->resume_from < 0 ) { if(conn->resume_from < 0 ) { /* /* * This is meant to get the size of the present remote-file by itself. * This is meant to get the size of the present remote-file by itself. * We don't support this now. Bail out! * We don't support this now. Bail out! */ */ data->resume_from = 0; conn->resume_from = 0; } } if(data->resume_from) { if(conn->resume_from) { /* do we still game? */ /* do we still game? */ int passed=0; int passed=0; Loading @@ -522,7 +522,7 @@ CURLcode Curl_http(struct connectdata *conn) input. If we knew it was a proper file we could've just input. If we knew it was a proper file we could've just fseek()ed but we only have a stream here */ fseek()ed but we only have a stream here */ do { do { int readthisamountnow = (data->resume_from - passed); int readthisamountnow = (conn->resume_from - passed); int actuallyread; int actuallyread; if(readthisamountnow > BUFSIZE) if(readthisamountnow > BUFSIZE) Loading @@ -537,11 +537,11 @@ CURLcode Curl_http(struct connectdata *conn) passed); passed); return CURLE_READ_ERROR; return CURLE_READ_ERROR; } } } while(passed != data->resume_from); /* loop until done */ } while(passed != conn->resume_from); /* loop until done */ /* now, decrease the size of the read */ /* now, decrease the size of the read */ if(data->infilesize>0) { if(data->infilesize>0) { data->infilesize -= data->resume_from; data->infilesize -= conn->resume_from; if(data->infilesize <= 0) { if(data->infilesize <= 0) { failf(data, "File already completely uploaded\n"); failf(data, "File already completely uploaded\n"); Loading @@ -551,7 +551,7 @@ CURLcode Curl_http(struct connectdata *conn) /* we've passed, proceed as normal */ /* we've passed, proceed as normal */ } } } } if(data->bits.set_range) { if(conn->bits.use_range) { /* /* * A range is selected. We use different headers whether we're downloading * A range is selected. We use different headers whether we're downloading * or uploading and we always let customized headers override our internal * or uploading and we always let customized headers override our internal Loading @@ -559,23 +559,23 @@ CURLcode Curl_http(struct connectdata *conn) */ */ if((data->httpreq == HTTPREQ_GET) && if((data->httpreq == HTTPREQ_GET) && !checkheaders(data, "Range:")) { !checkheaders(data, "Range:")) { conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", data->range); conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n", conn->range); } } else if((data->httpreq != HTTPREQ_GET) && else if((data->httpreq != HTTPREQ_GET) && !checkheaders(data, "Content-Range:")) { !checkheaders(data, "Content-Range:")) { if(data->resume_from) { if(conn->resume_from) { /* This is because "resume" was selected */ /* This is because "resume" was selected */ long total_expected_size= data->resume_from + data->infilesize; long total_expected_size= conn->resume_from + data->infilesize; conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n", conn->allocptr.rangeline = aprintf("Content-Range: bytes %s%ld/%ld\r\n", data->range, total_expected_size-1, conn->range, total_expected_size-1, total_expected_size); total_expected_size); } } else { else { /* Range was selected and then we just pass the incoming range and /* Range was selected and then we just pass the incoming range and append total size */ append total size */ conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%d\r\n", conn->allocptr.rangeline = aprintf("Content-Range: bytes %s/%d\r\n", data->range, data->infilesize); conn->range, data->infilesize); } } } } } } Loading Loading @@ -610,7 +610,7 @@ CURLcode Curl_http(struct connectdata *conn) conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"", conn->allocptr.proxyuserpwd)?conn->allocptr.proxyuserpwd:"", (conn->bits.user_passwd && conn->allocptr.userpwd)? (conn->bits.user_passwd && conn->allocptr.userpwd)? conn->allocptr.userpwd:"", conn->allocptr.userpwd:"", (data->bits.set_range && conn->allocptr.rangeline)? (conn->bits.use_range && conn->allocptr.rangeline)? conn->allocptr.rangeline:"", conn->allocptr.rangeline:"", (data->useragent && *data->useragent && conn->allocptr.uagent)? (data->useragent && *data->useragent && conn->allocptr.uagent)? conn->allocptr.uagent:"", conn->allocptr.uagent:"", Loading
lib/progress.c +9 −5 Original line number Original line Diff line number Diff line Loading @@ -91,11 +91,12 @@ static char *max5data(double bytes, char *max5) */ */ void Curl_pgrsDone(struct UrlData *data) void Curl_pgrsDone(struct connectdata *conn) { { struct UrlData *data = conn->data; if(!(data->progress.flags & PGRS_HIDE)) { if(!(data->progress.flags & PGRS_HIDE)) { data->progress.lastshow=0; data->progress.lastshow=0; Curl_pgrsUpdate(data); /* the final (forced) update */ Curl_pgrsUpdate(conn); /* the final (forced) update */ fprintf(data->err, "\n"); fprintf(data->err, "\n"); } } } } Loading Loading @@ -172,7 +173,7 @@ void Curl_pgrsSetUploadSize(struct UrlData *data, double size) */ */ int Curl_pgrsUpdate(struct UrlData *data) int Curl_pgrsUpdate(struct connectdata *conn) { { struct timeval now; struct timeval now; int result; int result; Loading @@ -185,6 +186,8 @@ int Curl_pgrsUpdate(struct UrlData *data) double total_transfer; double total_transfer; double total_expected_transfer; double total_expected_transfer; struct UrlData *data = conn->data; int nowindex = data->progress.speeder_c% CURR_TIME; int nowindex = data->progress.speeder_c% CURR_TIME; int checkindex; int checkindex; int count; int count; Loading @@ -198,15 +201,16 @@ int Curl_pgrsUpdate(struct UrlData *data) double total_estimate; double total_estimate; if(data->progress.flags & PGRS_HIDE) if(data->progress.flags & PGRS_HIDE) ; /* We do enter this function even if we don't wanna see anything, since ; /* We do enter this function even if we don't wanna see anything, since this is were lots of the calculations are being made that will be used this is were lots of the calculations are being made that will be used even when not displayed! */ even when not displayed! */ else if(!(data->progress.flags & PGRS_HEADERS_OUT)) { else if(!(data->progress.flags & PGRS_HEADERS_OUT)) { if (!data->progress.callback) { if (!data->progress.callback) { if(data->resume_from) if(conn->resume_from) fprintf(data->err, "** Resuming transfer from byte position %d\n", fprintf(data->err, "** Resuming transfer from byte position %d\n", data->resume_from); conn->resume_from); fprintf(data->err, fprintf(data->err, " %% Total %% Received %% Xferd Average Speed Time Curr.\n" " %% Total %% Received %% Xferd Average Speed Time Curr.\n" " Dload Upload Total Current Left Speed\n"); " Dload Upload Total Current Left Speed\n"); Loading
lib/progress.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -36,13 +36,13 @@ typedef enum { TIMER_LAST /* must be last */ TIMER_LAST /* must be last */ } timerid; } timerid; void Curl_pgrsDone(struct UrlData *data); void Curl_pgrsDone(struct connectdata *); void Curl_pgrsStartNow(struct UrlData *data); void Curl_pgrsStartNow(struct UrlData *data); void Curl_pgrsSetDownloadSize(struct UrlData *data, double size); void Curl_pgrsSetDownloadSize(struct UrlData *data, double size); void Curl_pgrsSetUploadSize(struct UrlData *data, double size); void Curl_pgrsSetUploadSize(struct UrlData *data, double size); void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size); void Curl_pgrsSetDownloadCounter(struct UrlData *data, double size); void Curl_pgrsSetUploadCounter(struct UrlData *data, double size); void Curl_pgrsSetUploadCounter(struct UrlData *data, double size); int Curl_pgrsUpdate(struct UrlData *data); int Curl_pgrsUpdate(struct connectdata *); void Curl_pgrsTime(struct UrlData *data, timerid timer); void Curl_pgrsTime(struct UrlData *data, timerid timer); Loading