commit - d26cab49f3ea5045a51e36dd8314bf996aeab302
commit + 8e1fcd55c45b2b550cec5585276e93d7f5d896fe
blob - 8d8ebb693f81dbed4045da8fa1c57f90b2e362a2
blob + 02951a4033a9780646d80ed187c221487167e497
--- 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", getprogname(), line);
+ fprintf(stderr, "%s: response: %s\n", 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);
+
+ n = 0;
+ while (verbose && n + 4 < r) {
+ buf[n + 4] = '\0';
+ t = hexstrtonum(&buf[n], 0, sizeof(buf) - n, &errstr);
+ if (errstr != NULL) {
+ warnx("pktline len is %s", errstr);
+ goto err;
+ }
+
+ if (t < 6) {
+ warnx("pktline len is too small");
+ goto err;
+ }
+
+ 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;
+ }
}
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;
}