From cd2dbb2e146562c9e37c614bb09a24f7fbf135e0 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 3 Dec 2020 22:26:46 +0100 Subject: Quite important network stuff --- apps/browser.c | 13 +++++++------ apps/server.c | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'apps') diff --git a/apps/browser.c b/apps/browser.c index c7c303f..6ed83b2 100644 --- a/apps/browser.c +++ b/apps/browser.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -88,13 +89,13 @@ void on_submit(void *event, struct element *box) struct socket *socket = net_open(S_TCP); if (socket && net_connect(socket, ip, port, NET_TIMEOUT)) { net_send(socket, query, strlen(query)); - char buf[4096] = { 0 }; - if (!net_receive(socket, buf, 4096, NET_TIMEOUT) || - !html_render(output, http_data(buf), 4096)) + char *buf = NULL; + if (!(buf = http_receive(socket)) || !html_render(output, http_data(buf), 4096)) { print_error("HTML parsing failed.\n"); - - c->text = http_code(buf); - c->color_fg = status_color(c->text); + } else { + c->text = http_code(buf); + c->color_fg = status_color(c->text); + } } else { print_error("Can't connect to server.\n"); c->text = strdup("000"); diff --git a/apps/server.c b/apps/server.c index 6aca617..3d3bb77 100644 --- a/apps/server.c +++ b/apps/server.c @@ -1,6 +1,7 @@ // MIT License, Copyright (c) 2020 Marvin Borner #include +#include #include #include #include -- cgit v1.2.3