aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2020-12-03 22:26:46 +0100
committerMarvin Borner2020-12-03 22:26:46 +0100
commitcd2dbb2e146562c9e37c614bb09a24f7fbf135e0 (patch)
tree12605be6b6dfe837f1a2ebefef3cfbc1ed8536e5 /apps
parentd525526f52c76156c4b9ee5ee4f14ed0d06547bc (diff)
Quite important network stuff
Diffstat (limited to 'apps')
-rw-r--r--apps/browser.c13
-rw-r--r--apps/server.c1
2 files changed, 8 insertions, 6 deletions
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 <gfx.h>
#include <gui.h>
#include <html.h>
+#include <http.h>
#include <input.h>
#include <mem.h>
#include <net.h>
@@ -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 <assert.h>
+#include <http.h>
#include <mem.h>
#include <net.h>
#include <print.h>