commit - 19c4311b55a37c4472ca0e84ce71937196e32925
commit + cf1195ce46eb4d534f737f60e91bfe591e82514c
blob - 6de46c7b396d96f52f0fa0a0c0136787754a52cd
blob + f1dd97eab93758c77c0b690753e3ddb2d60421c5
--- telescope.c
+++ telescope.c
static void load_gemini_url(struct tab*, const char*);
static void load_via_proxy(struct tab *, const char *,
struct proxy *);
+static void make_request(struct tab *, struct get_req *, int,
+ const char *);
static int do_load_url(struct tab*, const char *, const char *);
static void parse_session_line(char *, const char **, uint32_t *);
static void load_last_session(void);
struct get_req req;
size_t len;
char *at;
-
- stop_tab(tab);
- tab->id = tab_new_id();
memset(&req, 0, sizeof(req));
if (*tab->uri.port != '\0')
/* +1 to skip the initial `/' */
strlcpy(req.req, tab->uri.path+1, sizeof(req.req));
}
-
strlcat(req.req, "\r\n", sizeof(req.req));
- req.proto = PROTO_FINGER;
-
- ui_send_net(IMSG_GET_RAW, tab->id, &req, sizeof(req));
-
textplain_initparser(&tab->buffer.page);
+ make_request(tab, &req, PROTO_FINGER, NULL);
}
static void
load_gemini_url(struct tab *tab, const char *url)
{
struct get_req req;
-
- stop_tab(tab);
- tab->id = tab_new_id();
memset(&req, 0, sizeof(req));
strlcpy(req.host, tab->uri.host, sizeof(req.host));
strlcpy(req.port, tab->uri.port, sizeof(req.host));
- strlcpy(req.req, tab->hist_cur->h, sizeof(req.req));
- strlcat(req.req, "\r\n", sizeof(req.req));
-
- req.proto = PROTO_GEMINI;
-
- ui_send_net(IMSG_GET_RAW, tab->id,
- &req, sizeof(req));
+ make_request(tab, &req, PROTO_GEMINI, tab->hist_cur->h);
}
static void
{
struct get_req req;
- stop_tab(tab);
- tab->id = tab_new_id();
- tab->proxy = p;
-
memset(&req, 0, sizeof(req));
strlcpy(req.host, p->host, sizeof(req.host));
strlcpy(req.port, p->port, sizeof(req.host));
- strlcpy(req.req, tab->hist_cur->h, sizeof(req.req));
- strlcat(req.req, "\r\n", sizeof(req.req));
+ tab->proxy = p;
- req.proto = p->proto;
+ make_request(tab, &req, p->proto, tab->hist_cur->h);
+}
- ui_send_net(IMSG_GET_RAW, tab->id,
- &req, sizeof(req));
+static void
+make_request(struct tab *tab, struct get_req *req, int proto, const char *r)
+{
+ stop_tab(tab);
+ tab->id = tab_new_id();
+ req->proto = proto;
+
+ if (r != NULL) {
+ strlcpy(req->req, r, sizeof(req->req));
+ strlcat(req->req, "\r\n", sizeof(req->req));
+ }
+
+ ui_send_net(IMSG_GET_RAW, tab->id, req, sizeof(*req));
}
/*