commit - 6d1e5fdc3f135929f40d4a92a6a4b8bc0f0a61e5
commit + 507e51543a1bead6c8b3d28a06e2d9a42128a497
blob - b0bc7c7d83c8479fd1d9b762eaf78551f430d1a4
blob + e6d3950b1c2fa7616f6a5e4df7e81874347259fe
--- libexec/got-fetch-http/Makefile
+++ libexec/got-fetch-http/Makefile
.include "../../got-version.mk"
PROG= got-fetch-http
-SRCS= got-fetch-http.c bufio.c hash.c error.c inflate.c pollfd.c
+SRCS= got-fetch-http.c bufio.c hash.c error.c inflate.c pkt.c pollfd.c
CPPFLAGS= -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - f59556fe906b0a5f6b8f565d12b387c701f2f4c7
blob + b9e126395c419d439c968c0b1b113ab6e1a26b37
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
#include <tls.h>
#include <unistd.h>
+#include "got_error.h"
#include "got_version.h"
#include "got_lib_pkt.h"
static int
get_refs(int https, const char *host, const char *port, const char *path)
{
- struct bufio bio;
- char buf[GOT_PKT_MAX];
- const char *errstr, *sufx = "/info/refs";
- size_t skip, chunksz = 0;
- ssize_t r;
- int chunked;
- int sock;
- int ret = -1;
+ struct bufio bio;
+ char buf[GOT_PKT_MAX];
+ const struct got_error *e;
+ const char *sufx = "/info/refs";
+ size_t chunksz = 0;
+ ssize_t r;
+ int skip;
+ int chunked;
+ int sock;
+ int ret = -1;
if ((sock = dial(https, host, port)) == -1)
return -1;
r = http_read(&bio, chunked, &chunksz, buf, 4);
if (r <= 0)
goto err;
- buf[4] = '\0';
- skip = hexstrtonum(buf, 0, INT_MAX, &errstr);
- if (errstr != NULL) {
- warnx("pktlen is %s", errstr);
+
+ e = got_pkt_readlen(&skip, buf, verbose);
+ if (e) {
+ warnx("%s", e->msg);
goto err;
}
upload_request(int https, const char *host, const char *port, const char *path,
FILE *in)
{
- struct bufio bio;
- const char *errstr;
- char buf[GOT_PKT_MAX];
- ssize_t r;
- size_t chunksz = 0;
- long long t;
- int chunked;
- int sock;
- int ret = -1;
+ struct bufio bio;
+ char buf[GOT_PKT_MAX];
+ const struct got_error *e;
+ ssize_t r;
+ size_t chunksz = 0;
+ int t;
+ int chunked;
+ int sock;
+ int ret = -1;
if ((sock = dial(https, host, port)) == -1)
return -1;
if (r != 4)
goto err;
- buf[4] = '\0';
- t = hexstrtonum(buf, 0, sizeof(buf), &errstr);
- if (errstr != NULL) {
- warnx("pktline len is %s", errstr);
+ e = got_pkt_readlen(&t, buf, verbose);
+ if (e) {
+ warnx("%s", e->msg);
goto err;
}