diff --git a/src/gmni.c b/src/gmni.c
index 1c3e5f2bebddf5b606d11acd8924562cabde9a6f..49abb8524a012c27249006dc45f4688a846e63c3 100644
--- a/src/gmni.c
+++ b/src/gmni.c
@@ -14,6 +14,7 @@ #include <termios.h>
#include <unistd.h>
#include <gmni/gmni.h>
#include <gmni/tofu.h>
+#include <gmni/url.h>
#include "util.h"
static void
@@ -227,12 +228,24 @@ opts.ssl_ctx = SSL_CTX_new(TLS_method());
gemini_tofu_init(&cfg.tofu, opts.ssl_ctx, &tofu_callback, &cfg);
bool exit = false;
// TODO: Better error
fprintf(stderr, "Error: invalid URL\n");
return 1;
int ret = 0, nredir = 0;
while (!exit) {
char *buf;
curl_url_get(url, CURLUPART_URL, &buf, 0);
struct gemini_response resp;
enum gemini_result r = gemini_request(url, &opts, &resp);
enum gemini_result r = gemini_request(buf, &opts, &resp);
free(buf);
if (r != GEMINI_OK) {
fprintf(stderr, "Error: %s\n", gemini_strerr(r, &resp));
ret = (int)r;
@@ -254,12 +267,16 @@ exit = true;
break;
}
char *new_url = gemini_input_url(url, input);
char *buf;
curl_url_get(url, CURLUPART_URL, &buf, 0);
char *new_url = gemini_input_url(buf, input);
assert(new_url);
free(input);
free(url);
url = new_url;
free(buf);
curl_url_set(url, CURLUPART_URL, new_url, 0);
goto next;
case GEMINI_STATUS_CLASS_REDIRECT:
if (++nredir >= max_redirect) {
@@ -270,8 +287,8 @@ exit = true;
goto next;
}
free(url);
url = strdup(resp.meta);
curl_url_set(url, CURLUPART_URL, resp.meta, 0);
if (!follow_redirects) {
if (header_mode == OMIT_HEADERS) {
fprintf(stderr, "REDIRECT: %d %s\n",
@@ -311,7 +328,12 @@ break;
}
if (output_file != NULL) {
ret = download_resp(stderr, resp, output_file, url);
char *buf;
curl_url_get(url, CURLUPART_URL, &buf, 0);
ret = download_resp(stderr, resp, output_file, buf);
free(buf);
break;
}
@@ -349,7 +371,7 @@ gemini_response_finish(&resp);
}
SSL_CTX_free(opts.ssl_ctx);
gemini_tofu_finish(&cfg.tofu);
return ret;
}
text/gemini
This content has been proxied by September (ba2dc).