How to resolve the algorithm HTTP step by step in the Icon and Unicon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm HTTP step by step in the Icon and Unicon 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 Icon and Unicon programming language
Source code in the icon programming language
link cfunc
procedure main(arglist)
get(arglist[1])
end
procedure get(url)
local f, host, port, path
url ? {
="http://" | ="HTTP://"
host := tab(upto(':/') | 0)
if not (=":" & (port := integer(tab(upto('/'))))) then port := 80
if pos(0) then path := "/" else path := tab(0)
}
write(host)
write(path)
f := tconnect(host, port) | stop("Unable to connect")
writes(f, "GET ", path | "/" ," HTTP/1.0\r\n\r\n")
while write(read(f))
end
|icon req.icn http://www.rosettacode.org
procedure main(arglist)
m := open(arglist[1],"m")
while write(read(m))
end
You may also check:How to resolve the algorithm Egyptian division step by step in the F# programming language
You may also check:How to resolve the algorithm Sorting algorithms/Comb sort step by step in the IS-BASIC programming language
You may also check:How to resolve the algorithm Range extraction step by step in the Julia programming language
You may also check:How to resolve the algorithm Sorting algorithms/Sleep sort step by step in the Sidef programming language
You may also check:How to resolve the algorithm Self-describing numbers step by step in the J programming language