diff --git a/checkin_notes b/checkin_notes index 88477097f6..33982eea00 100755 --- a/checkin_notes +++ b/checkin_notes @@ -26812,3 +26812,15 @@ David 6 April 2005 host_edit_form.php sched/ handle_request.C + +David 6 April 2005 + - Core client: deal correctly with HTTP servers that don't support + the Range: option. + Namely: if we issue an HTTP GET request with a Range option, + and the reply header is 200 OK (rather than 206 Partial Content) + then assume the server is sending us the whole file; + reset bytes_xfered and offset to zero, + and open the file in "wb" rather than "ab" mode. + + client/ + http.C,h diff --git a/client/http.C b/client/http.C index 4c7540a9f0..60b49a08a7 100644 --- a/client/http.C +++ b/client/http.C @@ -799,7 +799,16 @@ bool HTTP_OP_SET::poll(double) { case HTTP_OP_GET: htp->http_op_state = HTTP_STATE_REPLY_BODY; - htp->file = boinc_fopen(htp->outfile, "ab"); + // if server doesn't support range request, + // prepare to receive the entire file + // + if (htp->hrh.http_status == HTTP_STATUS_PARTIAL_CONTENT) { + htp->file = boinc_fopen(htp->outfile, "ab"); + } else { + htp->file = boinc_fopen(htp->outfile, "wb"); + htp->file_offset = 0; + htp->bytes_xferred = 0; + } if (!htp->file) { msg_printf(NULL, MSG_ERROR, "HTTP_OP_SET::poll(): can't open output file %s\n", diff --git a/client/http.h b/client/http.h index 755e744cd2..4f22e1d759 100644 --- a/client/http.h +++ b/client/http.h @@ -28,6 +28,7 @@ // official HTTP status codes #define HTTP_STATUS_OK 200 +#define HTTP_STATUS_PARTIAL_CONTENT 206 #define HTTP_STATUS_RANGE_REQUEST_ERROR 416 #define HTTP_STATUS_MOVED_PERM 301 #define HTTP_STATUS_MOVED_TEMP 302