How to resolve the algorithm HTTP step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm HTTP step by step in the zkl programming language

Table of Contents

Problem Statement

Access and print a URL's content (the located resource) to the console. There is a separate task for HTTPS Requests.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm HTTP step by step in the zkl programming language

Source code in the zkl programming language

url := ask(0,"URL: ");

host := url;
dir  := "/";
port := 80;
if (n := url.find("/"))  { dir  = url[n,*];    host = url[0,n];  }
if (n := host.find(":")) { port = host[n+1,*]; host = host[0,n]; }

get := "GET %s HTTP/1.0\r\nHost: %s:%s\r\n\r\n".fmt(dir,host,port.toInt());
println("-->",get);
server := Network.TCPClientSocket.connectTo(host,port);
server.write(get);
data := server.read(True);
println(data.text);

  

You may also check:How to resolve the algorithm Mandelbrot set step by step in the Metapost programming language
You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the VBA programming language
You may also check:How to resolve the algorithm 21 game step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Balanced brackets step by step in the Nim programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Stata programming language