commit - fe55fe41ebae13ff135eb0041f19a224015cbf29
commit + 60ac05357c165b2b9aa4836616db21eeaa4211ea
blob - e6d3950b1c2fa7616f6a5e4df7e81874347259fe
blob + 1ff020ff9eb02181df0c0c89dba5ac9e4a6cfc74
--- 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 pkt.c pollfd.c
+SRCS= got-fetch-http.c bufio.c hash.c error.c inflate.c pkt.c \
+ pollfd.c path.c
CPPFLAGS= -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - a62f4f48f936f8cb6c39475cec6af2804c62e233
blob + 302be74ffa6969c1d5a365a2cf1e9e6de1c2bade
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
*/
#include <sys/types.h>
+#include <sys/queue.h>
#include <sys/socket.h>
#include <err.h>
#include <unistd.h>
#include "got_error.h"
+#include "got_path.h"
#include "got_version.h"
#include "got_lib_pkt.h"
char *p, *req;
int r;
- if (path_sufx != NULL && *path && path[strlen(path) - 1] == '/')
- path_sufx++; /* skip the slash */
-
if (strcmp(method, "POST") == 0)
te = "\r\nTransfer-Encoding: chunked\r\n";
if (ctype)
chdr = "Content-Type: ";
- r = asprintf(&p, "%s/%s%s%s", path, path_sufx,
- query ? "?" : "", query ? query : "");
+ r = asprintf(&p, "%s%s/%s%s%s", got_path_is_absolute(path) ? "" :"/",
+ path, path_sufx, query ? "?" : "", query ? query : "");
if (r == -1)
err(1, "asprintf");
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;
goto err;
}
- if (http_open(&bio, https, "GET", host, port, path, sufx,
+ if (http_open(&bio, https, "GET", host, port, path, "info/refs",
"service=git-upload-pack", NULL) == -1)
goto err;
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
#endif
- if (http_open(&bio, https, "POST", host, port, path, "/git-upload-pack",
+ if (http_open(&bio, https, "POST", host, port, path, "git-upload-pack",
NULL, UPLOAD_PACK_REQ) == -1)
goto err;
main(int argc, char **argv)
{
struct pollfd pfd;
- const char *host, *port, *path;
+ const char *host, *port;
+ char *path;
int https = 0;
int ch;
host = argv[1];
port = argv[2];
path = argv[3];
+ got_path_strip_trailing_slashes(path);
if (get_refs(https, host, port, path) == -1)
errx(1, "failed to get refs");