aboutsummaryrefslogtreecommitdiff
path: root/lib/libfetch/http.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2015-12-16 09:20:45 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2015-12-16 09:20:45 +0000
commitadc1aa7a29f88a8d58a0839248d48c69fb9b12c8 (patch)
treeba16bc5865f6868432ab3f94b60e36e09e713b67 /lib/libfetch/http.c
parent0792bcbb54f88a8f059909e085d1481d88b44408 (diff)
downloadsrc-adc1aa7a29f88a8d58a0839248d48c69fb9b12c8.tar.gz
src-adc1aa7a29f88a8d58a0839248d48c69fb9b12c8.zip
As a followup to r292330, standardize on size_t and add a few comments.
Notes
Notes: svn path=/head/; revision=292332
Diffstat (limited to 'lib/libfetch/http.c')
-rw-r--r--lib/libfetch/http.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index 486733333e4e..206648dd464b 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -130,8 +130,8 @@ struct httpio
int chunked; /* chunked mode */
char *buf; /* chunk buffer */
size_t bufsize; /* size of chunk buffer */
- ssize_t buflen; /* amount of data currently in buffer */
- int bufpos; /* current read offset in buffer */
+ size_t buflen; /* amount of data currently in buffer */
+ size_t bufpos; /* current read offset in buffer */
int eof; /* end-of-file flag */
int error; /* error flag */
size_t chunksize; /* remaining size of current chunk */
@@ -215,6 +215,7 @@ http_fillbuf(struct httpio *io, size_t len)
if (io->eof)
return (0);
+ /* not chunked: just fetch the requested amount */
if (io->chunked == 0) {
if (http_growbuf(io, len) == -1)
return (-1);
@@ -227,6 +228,7 @@ http_fillbuf(struct httpio *io, size_t len)
return (io->buflen);
}
+ /* chunked, but we ran out: get the next chunk header */
if (io->chunksize == 0) {
switch (http_new_chunk(io)) {
case -1:
@@ -238,6 +240,7 @@ http_fillbuf(struct httpio *io, size_t len)
}
}
+ /* fetch the requested amount, but no more than the current chunk */
if (len > io->chunksize)
len = io->chunksize;
if (http_growbuf(io, len) == -1)