commit - c7d1a4d98cf513b3015d80f6948b25aad5929a17
commit + f571fea2849dfbb5568180ac8140282f5bc6b351
blob - 43858a3fc70b77963b5985f1bf6470bb24429296
blob + 141ea5ab9f3b8b1b2767cb4e947d7065f387b0f2
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
#include "got_compat.h"
#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");