diff options
author | Marvin Borner | 2020-11-24 14:03:14 +0100 |
---|---|---|
committer | Marvin Borner | 2020-11-24 14:03:14 +0100 |
commit | 0564c8006da7077064222d15a899b858ae2d7e61 (patch) | |
tree | bc2a2d23850d150a02882e7b489ff2ec92d5bde9 /apps | |
parent | 39f3538f7ee56dab414d62201235f8427b4a9592 (diff) |
Added port support in URLs
Diffstat (limited to 'apps')
-rw-r--r-- | apps/browser.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/browser.c b/apps/browser.c index 157ddbd..83292e9 100644 --- a/apps/browser.c +++ b/apps/browser.c @@ -132,6 +132,14 @@ void on_submit(void *event, struct element *box) (void)event; char *url = ((struct element_text_input *)box->data)->text; + u16 port = 80; + char *port_str = strchr(url, ':'); + if (port_str) { + port_str[0] = '\0'; + port_str++; + port = atoi(port_str); + } + char *path = strchr(url, '/'); if (path) { path[0] = '\0'; @@ -148,7 +156,7 @@ void on_submit(void *event, struct element *box) struct element_label *c = code_label->data; struct socket *socket = net_open(S_TCP); - if (socket && net_connect(socket, ip, 80, NET_TIMEOUT)) { + if (socket && net_connect(socket, ip, port, NET_TIMEOUT)) { net_send(socket, query, strlen(query)); char buf[4096] = { 0 }; char parsed[4096] = { 0 }; |