Merge branch 'mh/http-fread-api-fix'
A pair of private functions in http.c that had names similar to fread/fwrite did not return the number of elements, which was found to be confusing. * mh/http-fread-api-fix: Make fread/fwrite-like functions in http.c more like fread/fwrite.
This commit is contained in:
12
http.c
12
http.c
@ -176,7 +176,7 @@ size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
|
|||||||
memcpy(ptr, buffer->buf.buf + buffer->posn, size);
|
memcpy(ptr, buffer->buf.buf + buffer->posn, size);
|
||||||
buffer->posn += size;
|
buffer->posn += size;
|
||||||
|
|
||||||
return size;
|
return size / eltsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_CURL_IOCTL
|
#ifndef NO_CURL_IOCTL
|
||||||
@ -204,12 +204,12 @@ size_t fwrite_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
|
|||||||
struct strbuf *buffer = buffer_;
|
struct strbuf *buffer = buffer_;
|
||||||
|
|
||||||
strbuf_add(buffer, ptr, size);
|
strbuf_add(buffer, ptr, size);
|
||||||
return size;
|
return nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)
|
size_t fwrite_null(char *ptr, size_t eltsize, size_t nmemb, void *strbuf)
|
||||||
{
|
{
|
||||||
return eltsize * nmemb;
|
return nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void closedown_active_slot(struct active_request_slot *slot)
|
static void closedown_active_slot(struct active_request_slot *slot)
|
||||||
@ -2319,14 +2319,14 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
|
|||||||
BUG("curl_easy_getinfo for HTTP code failed: %s",
|
BUG("curl_easy_getinfo for HTTP code failed: %s",
|
||||||
curl_easy_strerror(c));
|
curl_easy_strerror(c));
|
||||||
if (slot->http_code >= 300)
|
if (slot->http_code >= 300)
|
||||||
return size;
|
return nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ssize_t retval = xwrite(freq->localfile,
|
ssize_t retval = xwrite(freq->localfile,
|
||||||
(char *) ptr + posn, size - posn);
|
(char *) ptr + posn, size - posn);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return posn;
|
return posn / eltsize;
|
||||||
posn += retval;
|
posn += retval;
|
||||||
} while (posn < size);
|
} while (posn < size);
|
||||||
|
|
||||||
@ -2339,7 +2339,7 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
|
|||||||
the_hash_algo->update_fn(&freq->c, expn,
|
the_hash_algo->update_fn(&freq->c, expn,
|
||||||
sizeof(expn) - freq->stream.avail_out);
|
sizeof(expn) - freq->stream.avail_out);
|
||||||
} while (freq->stream.avail_in && freq->zret == Z_OK);
|
} while (freq->stream.avail_in && freq->zret == Z_OK);
|
||||||
return size;
|
return nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct http_object_request *new_http_object_request(const char *base_url,
|
struct http_object_request *new_http_object_request(const char *base_url,
|
||||||
|
Reference in New Issue
Block a user