commit - bcf7cd444a9e9057ce6f48cfb03573b4972d7559
commit + fe08c8a762cda56356f90cbe27c11f4617b7e450
blob - d3283c409607632e6832eeae310b43f122ea16ba
blob + 8d8ebb693f81dbed4045da8fa1c57f90b2e362a2
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
#include <sys/socket.h>
#include <err.h>
-#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <netdb.h>
}
if (verbose > 0)
- fprintf(stderr, "%s: response: %s\n", getprogname(), line);
+ fprintf(stderr, "%s: response: %s", getprogname(), line);
if ((cp = strchr(line, ' ')) == NULL) {
warnx("malformed HTTP response");
int chunked;
int sock;
int ret = -1;
- int i, n;
- long long t;
if ((sock = dial(https, host, port)) == -1)
return -1;
if (r == 0)
break;
- if (r < 4)
- goto err;
-
fwrite(buf, 1, r, stdout);
-
- t = 0;
- n = 0;
- while (n + 4 <= r) {
- buf[n + 4] = '\0';
- t = hexstrtonum(&buf[n], 0, sizeof(buf) - n, &errstr);
- if (errstr != NULL) {
- fprintf(stderr, "pktline len is %s", errstr);
- goto err;
- }
-
- if (t == 0) {
- if (verbose) {
- fprintf(stderr, "%s: readpkt: 0000\n",
- getprogname());
- }
- break;
- }
-
- if (t < 6) {
- fprintf(stderr, "pktline len is too small");
- goto err;
- }
-
- if (verbose) {
- fprintf(stderr, "%s: readpkt: %lld:\t",
- getprogname(), t - 4);
- for (i = 5; i < t; i++) {
- if (isprint((unsigned char)buf[n + i]))
- fputc(buf[n + i], stderr);
- else
- fprintf(stderr, "[0x%.2x]",
- buf[n + i]);
- }
- fputc('\n', stderr);
- }
- n += t;
- }
- if (t == 0)
- break;
}
fflush(stdout);
if (r != t - 4)
goto err;
- if (verbose) {
- int i;
- fprintf(stderr, "%s: writepkt: %.4x:\t",
- getprogname(), (unsigned int)t);
- for (i = 4; i < t; i++) {
- if (isprint((unsigned char)buf[i]))
- fputc(buf[i], stderr);
- else
- fprintf(stderr, "[0x%.2x]", buf[i]);
- }
- fputc('\n', stderr);
- }
-
if (http_chunk(&bio, buf, t))
goto err;
}